Compare commits

..

231 Commits

Author SHA1 Message Date
Brian
131baefac3 fix date for 7.0 release 2007-06-22 16:41:36 -06:00
Brian
a450078b67 update version 2007-06-22 16:40:17 -06:00
Brian
f6b041bf6c bring in Eric's FreeBSD fixes for -pthread 2007-06-22 15:40:46 -06:00
Brian
4f340d181a set tentative 7.0 release date 2007-06-20 19:59:15 -06:00
Brian
b58e38e936 fix TEXTREL problem (bug 7459) 2007-06-12 09:52:05 -06:00
Brian
8713cb48a8 Fix TEXREL issues when using GLX_USE_TLS (see bug 7459). 2007-06-12 09:46:12 -06:00
Brian
277c5e57ed fix GLX_USE_TLS breakage 2007-06-12 08:57:39 -06:00
Brian
b3d62d5af5 disable depthBits check in check_compatible(), see bug 11161 2007-06-08 12:36:00 -06:00
Brian
9c0f0c8d81 remove old comment about DEFAULT_SOFTWARE_DEPTH_BITS 2007-06-08 12:35:37 -06:00
Brian
18a0a2a7ac document bug 11049 fix 2007-05-23 16:50:22 -06:00
Brian
8b99d9e33c restore GL_TEXTURE_LOD_BIAS in _mesa_PopAttrib(), bug 11049 2007-05-23 16:49:19 -06:00
Brian
01e7e153e3 document point attentuation fix 2007-05-23 08:59:02 -06:00
Brian
0ad4ca24d2 Fix point attentuation problem (bug 11042)
ctx->Point._Attentuation was computed in wrong place and the VB->Eye coord Z
array wasn't indexed correctly in run_point_stage().
2007-05-23 08:56:45 -06:00
Brian
724a155552 if light position is local, treat it as a homogeneous coord and divide by W (see bug 11009) 2007-05-21 10:55:15 -06:00
Roland Scheidegger
d38b74a316 fix miptree layout (i915) for small compressed mipmaps
This seems to work now. Also fix i945 set_level_info, need to match i915
behaviour for storing mip height, as it's assumed to be the mip width
(in texels) elsewhere and the division by 4 is done later (untested).
2007-05-19 04:43:50 +02:00
Roland Scheidegger
54cab4b47b fix copy & paste bug of previous commit, breaking dxt5 formats 2007-05-19 03:56:06 +02:00
Roland Scheidegger
c093666bc5 fix miptree comparison with compressed textures
TexelBytes is always 0 with compressed textures, thus would never match
mt->cpp. This caused constant blitting around of textures, and it fixes at
least the horrible performance of Q3 if compressed textures are enabled.
2007-05-19 01:39:54 +02:00
Roland Scheidegger
04972f6761 fix small s3tc mipmaps (#10968)
make sure that always whole blocks are uploaded.
(May still not work correctly if the top mip map is not at least a full block,
that is 4 pixels wide - not sure, but probably doesn't happen in real world)
2007-05-19 01:39:16 +02:00
Brian
67f8234622 set version to 7.0 2007-05-18 09:41:34 -06:00
Brian
201d6dbd9c fix STATE_HALF_VECTOR value (bug 10987) 2007-05-18 09:35:18 -06:00
Ian Romanick
fbcac5aa83 Refactor determining whether a texture target can use compressed format 2007-05-17 14:45:25 -07:00
Brian
2b72ab8f8f document glXDestroyPbuffer fix 2007-05-17 15:30:39 -06:00
Brian
0ea97b9408 In DestroyPbuffer(), use GetReq() intead of GetReqExtra(). See bug 10983. 2007-05-17 15:26:39 -06:00
Brian
28683ac7c0 version 7.0, not 7.1 2007-05-17 09:07:25 -06:00
Brian
c72e3e210f version should be 7.0 2007-05-17 09:04:19 -06:00
Ian Romanick
b0fe0d8a55 Bring framebuffer_texture's error checking more in-line with the spec. 2007-05-15 13:42:25 -07:00
Brian
c128c3ce8c master/trunk is now for Mesa 7.1 devel: bump versions 2007-05-14 14:30:36 -06:00
Bruce Merry
6efdf648f5 in __glXGetArrayType() return type, not enabled (bug 10938) 2007-05-14 09:38:23 -06:00
Brian
6a587c0124 comment about fixing uniform structs 2007-05-14 09:38:23 -06:00
Oliver McFadden
524c3336c4 r300: Enable the non-user-buffers code to compile. 2007-05-13 13:38:38 +00:00
Oliver McFadden
0e7e211055 r300: Use e32(0x0) rather than e32(0); makes greping for hex values easier. 2007-05-13 12:59:41 +00:00
Oliver McFadden
4e641bf3e9 r300: Use the defined values when writing to R300_RS_ROUTE_0. 2007-05-13 12:56:59 +00:00
Oliver McFadden
2189ff5e51 r300: Use the defined values when writing to R300_SE_VTE_CNTL.
You can verify this is correct with the following code.

  assert (0x043f ==
	  (R300_VTX_W0_FMT | R300_VPORT_X_SCALE_ENA | R300_VPORT_X_OFFSET_ENA
	   | R300_VPORT_Y_SCALE_ENA | R300_VPORT_Y_OFFSET_ENA |
	   R300_VPORT_Z_SCALE_ENA | R300_VPORT_Z_OFFSET_ENA));
2007-05-13 12:43:40 +00:00
Oliver McFadden
33a73466ae r300: Added a TODO comment for the R300_VAP_INPUT_ROUTE_[01]_0 values. 2007-05-13 12:36:27 +00:00
Oliver McFadden
13c0abd8a7 r300: Changed some more functions to static functions.
This required reordering some of the functions which is why the diff is a little
larger.
2007-05-13 09:09:30 +00:00
Oliver McFadden
82de92c0fb r300: Changed a couple of functions in r300_state.c to static functions. 2007-05-13 08:59:54 +00:00
Oliver McFadden
e4b8481f39 r300: Removed the unused r300_aos_rec (replaced by r300_dma_region) structure. 2007-05-13 08:43:30 +00:00
Oliver McFadden
b5990cec90 r300: Use #if 0 for disabled code, rather than commenting it out. 2007-05-13 08:28:51 +00:00
Oliver McFadden
d93642251e r300: Removed a couple of obsolete/commented out includes. 2007-05-13 08:21:50 +00:00
Oliver McFadden
c66fd808ac r300: A few very minor indenting corrections. 2007-05-13 07:51:41 +00:00
Oliver McFadden
73449270bb r300: Use the defined values for the interpolater (interp_magic) magic values. 2007-05-13 07:44:20 +00:00
Oliver McFadden
6f56e68ee3 r300: Use the defined values when writing to R300_VAP_INPUT_CNTL_[01].
You can verify this is correct with the following code.

  assert (0x00000001 == R300_INPUT_CNTL_0_COLOR);

  assert (0x00000405 ==
	  (R300_INPUT_CNTL_POS | R300_INPUT_CNTL_COLOR |
	   R300_INPUT_CNTL_TC0));
2007-05-13 06:39:24 +00:00
Oliver McFadden
65fae19383 Revert "r300: Perform the locking closer to the DRM texture upload call."
This reverts commit 93881edb46.
2007-05-12 17:18:57 +00:00
Roland Scheidegger
b78aec5767 bring over recent radeonMakeCurrent fixes for r300 to radeon/r200 2007-05-12 11:20:24 +02:00
Oliver McFadden
6bae7d40f7 r300: Removed the name argument to ALLOC_STATE; do the name via the macro. 2007-05-12 01:53:56 +00:00
Oliver McFadden
5f1f1f5704 r300: Renamed r300DoEmitState to r300EmitAtoms. 2007-05-12 01:13:54 +00:00
Oliver McFadden
93881edb46 r300: Perform the locking closer to the DRM texture upload call.
This might help if with attaching GDB if the driver gets into a -EAGAIN loop.
2007-05-12 00:14:33 +00:00
Oliver McFadden
56b99ace19 r300: Removed unused FORCE_32BITS_ELTS define. 2007-05-11 23:35:37 +00:00
Oliver McFadden
3aad47679e r300: Removed the unused CPT macro. 2007-05-11 23:33:47 +00:00
Oliver McFadden
dac5303692 r300: Moved r300PackFloat24 near r300PackFloat32. 2007-05-11 23:32:03 +00:00
Oliver McFadden
64b03f33ee r300: Added insert_at_tail to the ALLOC_STATE macro. 2007-05-11 23:13:08 +00:00
Oliver McFadden
b8b0dd1e20 Revert "r300: Merged radeon_span.c."
This reverts commit 0aa998b2ab.
2007-05-11 23:03:40 +00:00
Oliver McFadden
93f9e61f43 r300: Corrected another error; regexp replaced something it shouldn't have. 2007-05-11 22:26:47 +00:00
Oliver McFadden
f405fbb36d r300: Corrected some macro errors from the previous commit. 2007-05-11 22:23:31 +00:00
Oliver McFadden
5a09ea01e0 r300: Reduced the diff on radeon_lock.[ch]. 2007-05-11 22:21:19 +00:00
Oliver McFadden
98d25a5a28 r300: Initial work on merging radeon_lock.[ch]. 2007-05-11 22:02:52 +00:00
Oliver McFadden
0aa998b2ab r300: Merged radeon_span.c. 2007-05-11 21:56:10 +00:00
Oliver McFadden
b6087270a0 r300: Cleaned up function names in r300_texstate.c. 2007-05-11 21:45:14 +00:00
Oliver McFadden
3f709f16ef r300: Enable hardware 3D texture support. Fixes the stex3d demo. 2007-05-11 21:41:16 +00:00
Oliver McFadden
67363327e5 r300: Corrected a small error from 37cbf38c344012f9d6e938937dac3697b73721a8. 2007-05-11 21:41:16 +00:00
Oliver McFadden
bcaf8fc7b1 r300: Cleaned up the blend factor function. 2007-05-11 21:41:16 +00:00
Oliver McFadden
ef29d6af6c r300: Removed the r300BindProgram function; mesa default does better checking. 2007-05-11 21:41:16 +00:00
Oliver McFadden
6a69bb5864 r300: Removed deprecated/disabled VBO code from r300_mem.c
Also removed a couple of unused fields from the r300_memory_manager structure.
2007-05-11 21:41:16 +00:00
Oliver McFadden
cbd29adbc8 r300: Indented r300_mem.c; I forgot this because it used to be radeon_mm.c. 2007-05-11 21:41:16 +00:00
Oliver McFadden
c729e67321 r300: Use __FUNCTION__ not __func__.
Just for consistency; most of the code already uses __FUNCTION__.
2007-05-11 21:41:16 +00:00
Oliver McFadden
5b23d36613 r300: Assert if the primitive type is unknown; this can't really happen. 2007-05-11 21:41:16 +00:00
Oliver McFadden
a87390504f r300: Moved some code around in r300_render.c and general clean up. 2007-05-11 21:41:16 +00:00
Brian
cc358d861d user-declared uniform structs not supported yet (see bug 10908) 2007-05-11 15:35:12 -06:00
Brian
749e093e33 don't ignore return value of _slang_codegen_global_variable() 2007-05-11 15:34:29 -06:00
Brian
eab6e16522 remove some unneeded code in init_machine() 2007-05-11 15:12:40 -06:00
Oliver McFadden
1b39be3790 r300: Removed some checking in r300NumVerts that is not needed.
According to Aapo Tahkola the OpenGL specification defines the behaviour when
there are not enough vertices for the primitive type, thus DRI drivers do not
need to perform verification on the number of vertices per primitive.
2007-05-11 19:45:28 +00:00
Oliver McFadden
69ff5a3dbc r300: Function naming correction in r300_texmem.c. 2007-05-11 19:45:28 +00:00
Oliver McFadden
01ec508c7f r300: Cleaned up function names in r300_state.c. 2007-05-11 19:45:28 +00:00
Oliver McFadden
d4e3b0b2c2 r300: Cleaned up function naming in r300_emit.c. 2007-05-11 19:45:28 +00:00
Oliver McFadden
b63c70666f r300: Renamed r300_maos.c to r300_emit.c; it contains mostly emit code now. 2007-05-11 19:45:28 +00:00
Brian
c33c00764c Remove unused FB_* tokens, re-indent code. 2007-05-11 08:41:34 -06:00
Brian
6c342ad859 When feeding back texcoords, don't divide by W. See bug 10913. 2007-05-11 08:39:18 -06:00
Patrick Baggett
86e4f52f3c Fix some bugs related to loop counters and conditional branching. 2007-05-11 08:19:33 -06:00
Brian
f0707c789a more indentation fixes, remove 'register' keywords 2007-05-10 17:33:14 -06:00
Brian
aed53ba525 re-indent some code 2007-05-10 17:30:44 -06:00
Brian
3dec7c57b0 document exp(), mod() fixes 2007-05-10 16:14:16 -06:00
Brian
544e441f53 regenerated 2007-05-10 16:14:16 -06:00
Brian
fa546c367d Implement exp() in terms of __asm float_power. Fix typo in mod(vec4) function.
exp() was using __asm float_exp (OPCODE_EXP) but that computes base two, not e.
See bug 10907.
2007-05-10 16:14:15 -06:00
Ian Romanick
64a6a50155 Fix reversed enable logic in enable_texture
Fix bug inserted in commit c9e723e501.
Discovered by Oliver McFadden (z3ro).
2007-05-10 15:01:52 -07:00
Oliver McFadden
c103453d4f r300: Added TODO comment regarding texture tiling; I'm not sure about this. 2007-05-10 22:01:41 +00:00
Oliver McFadden
d7e3d1dc42 r300: Corrected a compile error introduced by one of the previous commits. 2007-05-10 21:40:20 +00:00
Oliver McFadden
02e44e41c8 r300: Removed obsolete start_index16_packet/start_index32_packet.
It's all in r300_render.c now.
2007-05-10 21:28:04 +00:00
Oliver McFadden
eed67a6e3e r300: Moved some more emit code into r300_render.c. 2007-05-10 19:24:16 +00:00
Oliver McFadden
e856edb279 r300: Moved some more of the emit code into r300_render.c. 2007-05-10 19:24:16 +00:00
Brian
58239d2ae3 document tex sampler bug fix, code changes 2007-05-10 10:52:19 -06:00
Brian
2f6a0840c4 Replace pkg-config --cflags libdrm with LIBDRM_CFLAGS, remove disabled lines, remove obsolete comments. 2007-05-10 10:51:54 -06:00
Ian Romanick
c9e723e501 Convert "bit" parameters to GLbitfield. Fix cut-and-paste bug in _mesa_IsEnabled
These changes are based on patch review comments from Brian Paul, Alan
Hourihane, and vehemens.
2007-05-10 08:20:42 -07:00
Ian Romanick
87a980a795 Refactor the loop in unbind_texobj_from_texunits.
Common code was pulled out of the per-target if-statment and put at the end
of the for-loop.  The common code is guarded by a new variable, curr, that
is set to point to the unit's current target in each if-statement.
2007-05-10 08:20:41 -07:00
Ian Romanick
e282f89a38 Refactor queries of GL_(SOURCE|OPERAND)[012]_(ALPHA|RGB).
Most switch-statements that have cases for these enums already use code like:

    const GLuint idx = pname - GL_SOURCE0_RGB;
    ... texUnit->Combine.SourceRGB[idx] ...

This patch just brings the remaining bits up to speed.
2007-05-10 08:20:41 -07:00
Ian Romanick
e2e4b60c7d Refactor the way TestProxyTexImage is called in texture_error_check. 2007-05-10 08:20:41 -07:00
Ian Romanick
58dacc8df1 Refactor Enable / Disable and IsEnabled bits related to texture targets. 2007-05-10 08:20:41 -07:00
Oliver McFadden
b470189378 r300: Name the render functions in r300_render.c consistently. 2007-05-09 22:43:01 +00:00
Oliver McFadden
574bf4d346 r300: Return -1 for error. 2007-05-09 22:43:01 +00:00
Oliver McFadden
795ebb1a3b r300: Probably a good idea to always check the vertices; it's a WARN_ONCE so the
performance impact is extremely minimal.
2007-05-09 22:43:01 +00:00
Oliver McFadden
d0be8b959a r300: Added some more Doxygen documentation and made some functions static. 2007-05-09 22:43:01 +00:00
Oliver McFadden
672ecba175 r300: Removed the "texmicrotile" variable; the tiling code is disabled via a
compiler conditional anyway; probably broken?
2007-05-09 22:43:01 +00:00
Oliver McFadden
0dcea4bf8e r300: Converted a few "if (0)" into "if (RADEON_DEBUG & DEBUG_TEXTURE)". 2007-05-09 22:43:01 +00:00
Brian
16c503f39a Tweak the shell scripting for descending into and building subdirs.
In general, use this:
	@for dir in $(SUBDIRS) ; do \
		if [ -d $$dir ] ; then \
			(cd $$dir && $(MAKE)) || exit 1; \
		fi \
	done

Basically, silently skip missing subdirs but generate an error and stop if
there's a compilation or install problem.
This was done inconsistantly before.  In once case, a missing subdir was
causing us to go into an infinte loop!
2007-05-09 16:23:11 -06:00
Oliver McFadden
4d5d4e1f97 r300: Cleaned up radeon_context.h slightly; mostly Indent. 2007-05-09 21:06:28 +00:00
Oliver McFadden
a9ab36b8f2 r300: radeon_span.h is now common code; radeon_span.c still needs some work. 2007-05-09 20:52:09 +00:00
Oliver McFadden
88288b614e r300: Renamed the R300 memory manager from "radeon" to "r300"; it's R300
specific.
2007-05-09 20:49:49 +00:00
Oliver McFadden
a154706061 r300: Indented radeon_span.h 2007-05-09 20:41:27 +00:00
Oliver McFadden
6fe41a4c01 r300: Further reduced the radeon_span.c diff. 2007-05-09 20:36:48 +00:00
Oliver McFadden
f4a2b9f83d r300: I have no idea why this was forced on, but it seems to work fine when
restored to the previous behaviour.
2007-05-09 19:30:59 +00:00
Oliver McFadden
56c2f7bb42 r300: Removed the dangerous R300_SPAN_DISABLE_LOCKING flag.
Enabling R300_SPAN_DISABLE_LOCKING would probably cause more lockups; I think
there are a couple of other little bugs in this code, too. It's best to remove
it.
2007-05-09 19:24:59 +00:00
Oliver McFadden
df747eb354 r300: Removed a bit of disabled code. 2007-05-09 18:44:56 +00:00
Oliver McFadden
ff7a41a159 r300: Don't need to include the deprecated r300_program.h in some files.
The only file that still requires r300_program.h is r300_ioctl.c; and it should
use the new defines in r300_reg.h!
2007-05-09 18:37:46 +00:00
Oliver McFadden
01fdb34b39 r300; Indent would destroy r300_reg.h, so add *INDENT-OFF*. 2007-05-09 18:31:04 +00:00
Christoph Bill
3c9e5cb0bd r300: Added a few more Doxygen comments. 2007-05-09 18:25:12 +00:00
Christoph Bill
a6aa1f8016 r300: Added some Doxygen comments. 2007-05-09 18:24:06 +00:00
Oliver McFadden
967c2d220d r300: Converted "rp" variables (r300_fragment_program) to "fp". 2007-05-09 18:14:42 +00:00
Oliver McFadden
0e6b7eb9c0 r300: Don't need to sleep here; might cause performance problems the first time. 2007-05-09 18:11:38 +00:00
Oliver McFadden
ed42bd6e20 r300: Removed the obsolete GLX_DIRECT_RENDERING define. 2007-05-09 18:07:16 +00:00
Oliver McFadden
2db667290a r300: Further reduced the diff between radeon_span.[ch]. 2007-05-09 18:06:10 +00:00
Oliver McFadden
cea0c2b144 r300: Indented both copies of radeon_span.[ch] in preparation for merging. 2007-05-09 18:01:43 +00:00
Oliver McFadden
2b5ef29a7b r300: Removed the deprecated VTXFMT code.
This was okayed by Jerome Glisse and Keith Whitwell on the dri-devel IRC channel
and list, respectively.
2007-05-09 16:10:08 +00:00
Oliver McFadden
4ed59c6012 r300: The empty check_space doesn't and never has done anything; removed it. 2007-05-09 15:57:30 +00:00
Oliver McFadden
7e7b1f7c4d r300: Fix a couple of static errors. 2007-05-09 15:38:18 +00:00
Oliver McFadden
c48e4c6f09 r300: Fixed indenting from previous commit
d28f6d9176.
2007-05-09 15:28:38 +00:00
Oliver McFadden
4f20fe8a93 r300: Added R300_PRIM_NUM_VERTICES_MASK suggested by Jerome Glisse. 2007-05-09 15:21:13 +00:00
Oliver McFadden
d28f6d9176 r300: Fixed some more function names.
Note there might be some calls to the old function names in conditionally
disabled code, but I think I've got them all.
2007-05-09 15:19:05 +00:00
Oliver McFadden
fe6a2c4295 r300: Changed r300_run_vb_render calls to r300RunRender in some conditionally
disabled code.
2007-05-09 15:07:34 +00:00
Oliver McFadden
faf47d9f84 r300: Added a "not implemented yet" comment back. 2007-05-09 14:45:42 +00:00
Oliver McFadden
f9828f5c4f Merge branch 'master' of git://anongit.freedesktop.org/git/mesa/mesa 2007-05-09 14:23:22 +00:00
Oliver McFadden
7b165de5f8 r300: Last of the indent changes. :) 2007-05-09 14:19:45 +00:00
Brian
62ef001de7 add pointers to git repo for drm/libpciaccess, replace & with & 2007-05-09 08:17:57 -06:00
Oliver McFadden
76d7b62cd2 r300: Indented r300_cmdbuf.[ch]. 2007-05-09 14:17:16 +00:00
Oliver McFadden
901fc0de18 r300: Indented r300_state.[ch]. 2007-05-09 14:12:34 +00:00
Oliver McFadden
c970811dab r300: Indented r300_texmem.[ch]. 2007-05-09 14:11:17 +00:00
Oliver McFadden
bb97694fad r300: Indented r300_texstate.[ch] 2007-05-09 14:09:35 +00:00
Brian
516259d609 Clean-up in I830AllocVidMem(), s/int/unsigned long/ for ret variable. 2007-05-09 08:07:15 -06:00
Brian
3e4302fe3b Check that texture units/samplers specified with glUniform1i() are legal. 2007-05-09 08:07:15 -06:00
Oliver McFadden
dcc8e5f4c1 r300: Indented r300_tex.[ch]. 2007-05-09 13:59:28 +00:00
Oliver McFadden
32c8d002d0 r300: Indented r300_context.[ch]. 2007-05-09 13:55:14 +00:00
Oliver McFadden
c9b87b8ad8 r300: Removed the unused immediate vertices mode macro.
Immediate vertices mode hasn't been supported since early CVS versions of the
R300 driver.
2007-05-09 04:30:16 +00:00
Oliver McFadden
5d61cfd1fd r300: Removed a disabled/obsolete e32 in the AOS function. 2007-05-09 04:27:31 +00:00
Oliver McFadden
93e957cc65 r300: Removed some disabled R200 code from the R300 driver. 2007-05-09 04:25:27 +00:00
Oliver McFadden
3eae496deb r300: Don't indent the tables in r300_texstate.c. 2007-05-09 04:20:35 +00:00
Oliver McFadden
81c6516af1 r300: Indented r300_vertprog.[ch]. 2007-05-09 04:12:04 +00:00
Oliver McFadden
9e91351826 r300: Indented r300_fragprog.[ch]. 2007-05-09 04:08:27 +00:00
Oliver McFadden
328b307e2f r300: Cleaned up the R300 Makefile. 2007-05-09 03:44:40 +00:00
Oliver McFadden
d316b4dc22 r300: Corrected a couple of "control reaches end of non-void function" warnings. 2007-05-09 03:40:06 +00:00
Oliver McFadden
f0126a76ac r300: Corrected an error in r300_vertprog.c.
Cannot use _mesa_warning here because we don't have a context pointer; perhaps
R300 specific warning and error functions are needed.
2007-05-09 03:38:45 +00:00
Oliver McFadden
b8640db021 r300: Corrected the exit codes for consistency; they are all -1 for error now.
The one exception is 300FlushCmdBuf.
2007-05-09 03:36:28 +00:00
Oliver McFadden
28b47110b6 r300: Converted exit calls to _mesa_exit calls.
Note that the exit codes are inconsistent and should be fixed.
2007-05-09 03:32:15 +00:00
Oliver McFadden
fe2c58d2d5 r300: Converted a few fprintf calls to _mesa_warning calls. 2007-05-09 03:25:33 +00:00
Oliver McFadden
4917955205 r300: Added a warning when texture state update fails. 2007-05-09 03:22:37 +00:00
Oliver McFadden
eca50a27e1 r300: Removed some obsolete code from r300_tex.c. 2007-05-09 03:18:14 +00:00
Oliver McFadden
0950e9727e mesa: Added Vim swap files to .gitignore. 2007-05-09 03:14:08 +00:00
Oliver McFadden
504fafe389 r300: Updated .gitignore. 2007-05-09 03:12:51 +00:00
Oliver McFadden
72608aedc3 r300: Added the Linux Kernel indent script. 2007-05-09 03:12:22 +00:00
Oliver McFadden
be56660ba0 r300: Indented r300_state.[ch]. 2007-05-09 02:59:11 +00:00
Oliver McFadden
36c8bc6141 r300: Indented r300_emit.h. 2007-05-09 02:52:37 +00:00
Oliver McFadden
5c8296a6ab r300: Indented r300_cmdbuf.[ch]. 2007-05-09 02:51:13 +00:00
Oliver McFadden
6665658a56 r300: Indented r300_shader.[ch]. 2007-05-09 02:50:13 +00:00
Oliver McFadden
204bc4e441 r300: Indented r300_maos.[ch]. 2007-05-09 02:49:14 +00:00
Oliver McFadden
e90ad3dbbb r300: Indented r300_ioctl.[ch]. 2007-05-09 02:46:57 +00:00
Oliver McFadden
8d62afdb6a r300: Removed the obsolete pfs_reg_t type from r300_fragprog.h. 2007-05-09 02:41:38 +00:00
Oliver McFadden
59494bafb4 r300: Use an array for the vertex program sources and corrected an error from
4960af08ad.
2007-05-09 02:35:07 +00:00
Oliver McFadden
33939fd29b r300: Removed the ugly CARD32 type. 2007-05-09 02:27:08 +00:00
Oliver McFadden
4960af08ad r300: Renamed vertex_shader.h to r300_vertprog.h 2007-05-09 02:24:59 +00:00
Oliver McFadden
f5b0cafbb1 r300: Removed obsolete pixel_shader.h header file. 2007-05-09 02:18:29 +00:00
Oliver McFadden
c578354642 r300: Renamed the VBO functions to the R300 name format. 2007-05-08 21:04:57 +00:00
Brian
da37ac5ee7 remove some debug code 2007-05-08 14:08:45 -06:00
Brian
ed2fddc98e special case for -pthread (bug 10876) 2007-05-08 14:03:04 -06:00
Brian
58eaf0acca a somewhat nicer demo w/ command line options 2007-05-08 13:48:52 -06:00
Oliver McFadden
d132f7245d r300: Removed some deprecated code from r300_context.c and corrected an unused
variable warning in r300_render.c.
2007-05-08 19:46:25 +00:00
Oliver McFadden
73bc8b63ac r300: Last few r300_render.c clean up. 2007-05-08 19:38:44 +00:00
Oliver McFadden
377ce9e074 r300: Merged some comments into the Doxygen documentation. 2007-05-08 19:35:36 +00:00
Oliver McFadden
f1d785188b r300: Cleaned up r300_render.c using Indent with appropriate options.
This corrects the mess of space and tab indenting that existed in this file, and
probably others. The diff is actually very small if you use an external diff
program and ignore whitespace.
2007-05-08 19:31:30 +00:00
Oliver McFadden
313c4c2643 r300: General render clean up; added some Doxygen documentation, too. 2007-05-08 19:22:15 +00:00
Oliver McFadden
fbeae4f70c r300: Moved the pipeline stages together for readability. 2007-05-08 18:47:26 +00:00
Oliver McFadden
9301a6a325 r300: Print the OpenGL define instead of a 2-digit char code in the warning. 2007-05-08 18:43:56 +00:00
Oliver McFadden
6c036812be r300: Clean up the vertex buffer emission code and reduced code duplication.
I tested both the unoptimized and optimized versions with Quake 3 Arena; there
are no problems.
2007-05-08 18:28:04 +00:00
Oliver McFadden
c6abbbfd02 r300: Cleaned up a lot of cruft in r300_render.c. 2007-05-08 18:05:10 +00:00
Dave Airlie
8a7f474c69 i915/miniglx: remove unused code 2007-05-08 10:53:43 +10:00
Dave Airlie
47e33a27df miniglx: fixup use of create windows x and y coordinates
This makes miniglx take not of the x and y from XCreateWindow
2007-05-08 10:51:44 +10:00
Dave Airlie
401629c721 miniglx/glut: should use the x/y pos to create window
This allows moving miniglx glut windows around the framebuffer
2007-05-08 10:49:31 +10:00
Brian
f1770c3210 better comments for _mesa_debug(), _mesa_warning(), etc 2007-05-07 14:13:23 -06:00
Dave Airlie
8130a4fe98 radeon: enable xpress chipsets
glxgears and googleearth now run so that seems like a good start

Thanks to Aapo Tahkola for doing the 3D work on this so far, I got lost
after the GART changes.
2007-05-07 07:06:08 +10:00
Aapo Tahkola
8f1c63b263 rs480: fix secondary color for real this time 2007-05-06 19:25:45 +03:00
Aapo Tahkola
857ebc6d47 Merge branch 'master' of git+ssh://aapot@git.freedesktop.org/git/mesa/mesa 2007-05-06 19:19:16 +03:00
Aapo Tahkola
660bdc616b rs480: fix textures and secondary color(?). clipping is still busted. tested on r480 2007-05-06 19:18:10 +03:00
Aapo Tahkola
88ae491bd2 r300: fix broken vbos 2007-05-06 19:10:39 +03:00
Oliver McFadden
8445960d9f r300: Added R300_AA_DISABLE for R300_GB_AA_CONFIG. 2007-05-06 12:09:42 +00:00
Oliver McFadden
74cae00c0e r300: Removed more deprecated state code that is now set in separate functions. 2007-05-06 11:56:36 +00:00
Oliver McFadden
56d9663574 r300: R300_ZS_... is now set in separate functions; removed the deprecated code. 2007-05-06 11:54:00 +00:00
Oliver McFadden
81d1a04e04 r300: Point size is now set in a separate function; removed the deprecated code. 2007-05-06 11:52:03 +00:00
Oliver McFadden
62cbe6c3f3 r300: Use the defined values for R300_VAP_CNTL_STATUS. 2007-05-06 11:36:24 +00:00
Aapo Tahkola
16cec9f767 r300: fix primary color on rs480 2007-05-06 14:28:23 +03:00
Aapo Tahkola
5e2a66466d don't use hw to perform vertex transform etc. when using swtcl. This for compatibility with vertex programs and the fact that swtcl very rarely gets hit with tcl capable hw. 2007-05-05 17:07:46 +03:00
Dave Airlie
b3378f6cc5 nouveau: disable nouveau build by default
Until this is API/ABI stable building it by default isn't a good idea.
2007-05-05 15:43:01 +10:00
Brian
91948f99dd add </ol> tag 2007-05-04 18:32:02 -06:00
Brian
ae5f67575d Makefile clean-ups for miniglx. 2007-05-04 18:27:12 -06:00
Brian
e75fbd3f91 Assorted miniglx updates. 2007-05-04 18:26:41 -06:00
Brian
a6dad578b5 document R300 bug fix 10848 2007-05-03 13:52:33 -06:00
Brian
c6443eb1a3 fix some matrix/state token indexing bugs (see bug 10848) 2007-05-03 12:33:25 -06:00
Brian
121533defb add some #includes to silence warnings 2007-05-03 09:50:08 -06:00
Brian
3cddba688d get rid of normal vector 2007-05-02 18:55:45 -06:00
Brian
dc881e1909 get rid of OSMESA stuff 2007-05-02 18:54:57 -06:00
Brian
2dfb03beb2 New test of the dFdx(), dFdy() functions. 2007-05-02 18:48:51 -06:00
Brian
18cfe0c801 document recent GLSL, R300 fixes 2007-05-02 18:46:45 -06:00
Brian
60d136f63c changes to get DDX/DDY working again 2007-05-02 18:45:44 -06:00
Brian
62da6a1b3e Resuscitate some of the DDX,DDY code.
Only works for program input registers at this time.
Good enough for the common case of texcoords, though.
2007-05-02 18:44:34 -06:00
Brian
77e7535c0f fix some DDX,DDY mix-ups 2007-05-02 18:42:57 -06:00
Brian
5c1b53d58d Document a deficiency in the _swrast_Translate() function with regard to point size. 2007-05-02 12:06:43 -06:00
Brian
b2f1d6422b fix some renderbuffer/wrapper bugs 2007-05-02 08:48:43 -06:00
Brian
99f24c8d17 fix some StepX/StepY mix-ups in alpha interpolation 2007-05-02 08:48:20 -06:00
Brian
04c401c91e add *gc, *syn files to tarballs 2007-05-02 08:29:14 -06:00
Brian
03f201d935 regenerated 2007-05-01 14:03:16 -06:00
Brian
594b5ad87d implement acos(), asin(), atan() 2007-05-01 14:02:49 -06:00
Brian
bfd5cf72c4 fog, mix() bug fixes 2007-05-01 10:23:15 -06:00
Brian
7559364027 Rewrite of slang_inline_asm_function() to do full parameter/argument substitution.
We had been taking a short-cut w/ asm inlines by just using parameters in order
rather than doing full formal parameter -> actual argument substitution like
ordinary inlined function calls.  This worked in all cases but one: mix() in
which the parameters were used in a different order.
This fixes bug 10821.
2007-05-01 10:22:08 -06:00
Michel Dänzer
65faf02367 r300: Don't crash in radeonUpdatePageFlipping when !radeon->glCtx->DrawBuffer.
This feels like a kludge, maybe there's a better solution.
2007-04-30 18:28:24 +02:00
Michel Dänzer
c409dbcae3 r300: Page flipping fixes.
Mostly making sure the page flipping state is respected when necessary.
2007-04-29 13:52:48 +02:00
Michel Dänzer
cbf280dc26 r300: radeonMakeCurrent cleanups.
r300UpdateWindow is superfluous or even possibly wrong here; _mesa_make_current
will set the viewport when necessary. So the conditional _mesa_set_viewport call
can go as well.
2007-04-29 13:52:11 +02:00
Brian
af0ae93863 only load front/back face attrib if using a shader (bug 10788) 2007-04-28 08:51:23 -06:00
Brian
bcc3baadba use EMIT_1F or EMIT_4F for fog depending on fragment program (bug 10788) 2007-04-28 08:50:07 -06:00
Brian
4ca7c804db fix GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB bug (10787) 2007-04-28 08:01:18 -06:00
Keith Packard
bfaf6156fb additional checks that attr is a texcoord 2007-04-28 07:50:06 -06:00
Brian
d741b10be6 7.0 blurb 2007-04-27 17:05:29 -06:00
Brian
e371a5f084 Version bumps for 7.0 2007-04-27 17:01:23 -06:00
Brian
af846712fd updates for 7.0 2007-04-27 17:00:13 -06:00
Brian
c4615abb11 added 7.0 relnotes link 2007-04-27 16:54:05 -06:00
Brian
430e036413 added 6.5.3 MD5 sums 2007-04-27 16:53:42 -06:00
Brian
502ebe90e8 7.0 release notes (template) 2007-04-27 16:53:26 -06:00
127 changed files with 7214 additions and 8223 deletions

3
.gitignore vendored
View File

@@ -1,7 +1,8 @@
*~
*.a
*.o
*.so
*.sw[a-z]
*~
depend
depend.bak
lib

View File

@@ -7,7 +7,9 @@ SUBDIRS = src progs
default: $(TOP)/configs/current
@for dir in $(SUBDIRS) ; do \
(cd $$dir ; $(MAKE)) || exit 1 ; \
if [ -d $$dir ] ; then \
(cd $$dir && $(MAKE)) || exit 1 ; \
fi \
done
@@ -16,7 +18,9 @@ doxygen:
clean:
@for dir in $(SUBDIRS) ; do \
(cd $$dir ; $(MAKE) clean) ; \
if [ -d $$dir ] ; then \
(cd $$dir && $(MAKE) clean) ; \
fi \
done
@@ -34,9 +38,12 @@ realclean:
install:
@for dir in $(SUBDIRS) ; do \
(cd $$dir ; $(MAKE) install) || exit 1 ; \
if [ -d $$dir ] ; then \
(cd $$dir && $(MAKE) install) || exit 1 ; \
fi \
done
# DirectFBGL module installation
linux-directfb-install:
cd src/mesa/drivers/directfb && $(MAKE) install
@@ -155,10 +162,10 @@ ultrix-gcc:
# Rules for making release tarballs
DIRECTORY = Mesa-6.5.3
LIB_NAME = MesaLib-6.5.3
DEMO_NAME = MesaDemos-6.5.3
GLUT_NAME = MesaGLUT-6.5.3
DIRECTORY = Mesa-7.0
LIB_NAME = MesaLib-7.0
DEMO_NAME = MesaDemos-7.0
GLUT_NAME = MesaGLUT-7.0
MAIN_FILES = \
$(DIRECTORY)/Makefile* \
@@ -222,6 +229,9 @@ MAIN_FILES = \
$(DIRECTORY)/src/mesa/shader/slang/descrip.mms \
$(DIRECTORY)/src/mesa/shader/slang/sources \
$(DIRECTORY)/src/mesa/shader/slang/library/*.[ch] \
$(DIRECTORY)/src/mesa/shader/slang/library/*.gc \
$(DIRECTORY)/src/mesa/shader/slang/library/*.syn \
$(DIRECTORY)/src/mesa/shader/slang/library/Makefile \
$(DIRECTORY)/src/mesa/swrast/*.[ch] \
$(DIRECTORY)/src/mesa/swrast/descrip.mms \
$(DIRECTORY)/src/mesa/swrast/sources \

View File

@@ -100,6 +100,14 @@ do
-L*)
DEPS="$DEPS $1"
;;
-pthread)
# this is a special case (see bugzilla 10876)
DEPS="$DEPS $1"
;;
'-pthread')
# for FreeBSD
DEPS="$DEPS -pthread"
;;
'-cplusplus')
CPLUSPLUS=1
;;

View File

@@ -8,9 +8,9 @@
CONFIG_NAME = default
# Version info
MESA_MAJOR=6
MESA_MINOR=5
MESA_TINY=3
MESA_MAJOR=7
MESA_MINOR=1
MESA_TINY=0
# external projects. This should be useless now that we use libdrm.
DRM_SOURCE_PATH=$(TOP)/../drm

View File

@@ -27,9 +27,9 @@ ASM_SOURCES =
# Library/program dependencies
LIBDRM_CFLAGS = `pkg-config --cflags libdrm`
LIBDRM_LIB = `pkg-config --libs libdrm`
DRI_LIB_DEPS = -L/usr/local/lib -lm -lpthread -lexpat $(LIBDRM_LIB)
DRI_LIB_DEPS = -L/usr/local/lib -lm -pthread -lexpat $(LIBDRM_LIB)
GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lXdamage -lXfixes \
-lm -lpthread $(LIBDRM_LIB)
-lm -pthread $(LIBDRM_LIB)
GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -L/usr/X11R6/lib -lGLU -lGL -lX11 -lXmu -lXt -lXi -lm
GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -L/usr/X11R6/lib -lGL -lXt -lX11

View File

@@ -67,4 +67,4 @@ WINDOW_SYSTEM=dri
# gamma are missing because they have not been converted to use the new
# interface.
DRI_DIRS = i810 i915tex i915 i965 mach64 mga r128 r200 r300 radeon s3v \
savage sis tdfx trident unichrome ffb nouveau
savage sis tdfx trident unichrome ffb

View File

@@ -15,6 +15,13 @@ PIC_FLAGS = -fPIC
# Add '-DGLX_USE_TLS' to ARCH_FLAGS to enable TLS support.
ARCH_FLAGS ?=
# DRM and pciaccess
LIBDRM_CFLAGS = `pkg-config --cflags libdrm`
LIBDRM_LIB = `pkg-config --libs libdrm`
PCIACCESS_CFLAGS = `pkg-config --cflags pciaccess`
PCIACCESS_LIB = `pkg-config --libs pciaccess`
DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
-D_BSD_SOURCE -D_GNU_SOURCE -DHAVE_POSIX_MEMALIGN \
-DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DDRM_USE_MALLOC -DIN_DRI_DRIVER
@@ -28,7 +35,7 @@ CXXFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES)
ASM_SOURCES =
# Library/program dependencies
DRI_LIB_DEPS = -lm -lpthread -lexpat -ldl -L$(TOP)/$(LIB_DIR)
DRI_LIB_DEPS = -lm -lpthread -lexpat -ldl -L$(TOP)/$(LIB_DIR) $(PCIACCESS_LIB)
GL_LIB_DEPS = -lm -lpthread -ldl
GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm
GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lm
@@ -39,5 +46,5 @@ SRC_DIRS = glx/mini mesa glu glut/mini
DRIVER_DIRS = dri
PROGRAM_DIRS = miniglx
#DRI_DIRS = ffb gamma sis savage
DRI_DIRS = i810 i915 mach64 mga r128 r200 radeon tdfx unichrome fb
#DRI_DIRS = ffb gamma sis savage tdfx unichrome fb
DRI_DIRS = i810 i915tex i915 mach64 mga r128 r200 radeon

View File

@@ -88,19 +88,6 @@ driver (such as <code>radeon_dri.so</code>) at runtime. &nbsp;The
environment variable <code>LIBGL_DRIVERS_PATH</code> should name the
directory where these modules are located.<br>
<br>
Prior to running a MiniGXL application, the following kernel modules
must be installed:<br>
<br>
<div style="margin-left: 40px;"> agpgart.o<br>
radeonfb.o &nbsp;(assuming Radeon hardware)<br>
radeon.o &nbsp;(assuming Radeon hardware)<br>
</div>
<code></code> <br>
Finally, MiniGLX reads a configuration file (by default,<code>
/etc/miniglx.conf</code>) to determine basic configuration information.
&nbsp;The configuration file may also be located in the directory
specified by the <code>MINIGLX_CONF</code> environment variable).<br>
<br>
The remainder of this section describes the MiniGLX API functions.<br>
<br>
<h2>3.1 Initialization</h2>

View File

@@ -71,8 +71,8 @@ a:visited {
<li><a href="helpwanted.html" target="MainFrame">Help Wanted</a>
<li><a href="devinfo.html" target="MainFrame">Development Notes</a>
<li><a href="sourcedocs.html" target="MainFrame">Source Documentation</a>
<li><a href="subset.html" target="MainFrame">Subset Information</a>
<li><a href="fbdev-dri.html" target="MainFrame">fbdev/DRI Environment</a>
<li><a href="subset.html" target="MainFrame">Mesa Subset Driver</a>
<li><a href="glfbdev-driver.html" target="MainFrame">glFBDev Driver</a>
<LI><A HREF="dispatch.html" target="MainFrame">GL Dispatch</A>
</ul>

View File

@@ -9,11 +9,7 @@
<H1>Downloading</H1>
<p>
Last development release: <b>6.5.3</b>
</p>
<p>
Last stable release: <b>6.4.2</b>
Last stable release: <b>7.0</b>
</p>
<p>

View File

@@ -12,161 +12,77 @@
<H1>1. Introduction</H1>
<p>
The fbdev/DRI sub-project within Mesa brings hardware accelerated OpenGL
rendering to the Linux fbdev environment.
The X Window System / XFree86 is not needed.
The fbdev/DRI environment supports hardware-accelerated 3D rendering without
the X window system. This is typically used for embedded applications.
</p>
<p>
Basically, the <a href="http://dri.sf.net/">DRI</a> drivers for hardware
accelerated OpenGL for XFree86 have been ported to fbdev so that X is
not needed.
This means fbdev/DRI works in full-screen mode only.
Contributors to this project include Jon Smirl, Keith Whitwell and Dave Airlie.
</p>
<p>
DRI driver writers may find this simplified environment easier to work in,
compared to the full XFree86/DRI environment.
Applications in the fbdev/DRI environment use
the <a href="MiniGXL.html"> MiniGLX</a> interface to choose pixel
formats, create rendering contexts, etc. It's a subset of the GLX and
Xlib interfaces allowing some degree of application portability between
the X and X-less environments.
</p>
<p>
Much of the work for this project has been done by Jon Smirl and
Keith Whitwell.
</p>
<p>
To use fbdev/DRI, you'll need a Linux 2.4 or 2.6 kernel.
</p>
<h3>Background Info</h3>
<p>
The Mesa-based DRI drivers used to be hosted in the DRI tree (which is
basically a copy of the XFree86 tree).
Since the Mesa-based DRI drivers are moreso "Mesa drivers" than "XFree86
drivers" and the fact that with some work, the drivers could be used
without X, the driver code was moved into the Mesa tree.
</p>
<p>
So now the DRI drivers can be compiled for two different environments:
fbdev and XFree86.
To build the drivers for XFree86, one has to download/build the DRI
source tree.
Eventually, we'd like to be able to build the drivers for XFree86 outside
of the XFree86/DRI trees.
</p>
<h1>2. Compilation</h1>
<h2>2.1 Compiling the DRM modules</h2>
<p>
First, you'll need the DRM (Direct Rendering Manager) kernel module sources.
They're found in a module of the DRI CVS tree.
To obtain the code do the following:
You'll need the DRM and pciaccess libraries. Check with:
</p>
<pre>
cvs -d:pserver:anonymous@anoncvs.freedesktop.org:/cvs/dri login
</pre>
<p>
Press Enter/Return when prompted for a password. Then,
</p>
<pre>
cvs -d:pserver:anonymous@anoncvs.freedesktop.org:/cvs/dri co drm
pkg-config --modversion libdrm
pkg-config --modversion pciaccess
</pre>
<p>
Compile the DRM kernel modules:
You can get them from the git repository with:
</p>
<pre>
cd drm/linux
make
git clone git://anongit.freedesktop.org/git/mesa/drm
git clone git://anongit.freedesktop.org/git/xorg/lib/libpciaccess
</pre>
<p>
Note: you may need to be root in order to make a few symlinks.
See the README files in those projects for build/install instructions.
</p>
<p>
When compilation is done, you should have at least the following
kernel modules:
You'll need fbdev header files. Check with:
</p>
<pre>
gamma.o
i810.o
i830.o
mach64.o
mga.o
r128.o
radeon.o
savage.o
sis.o
tdfx.o
via.o
ls -l /usr/include/linux/fb.h
</pre>
<p>
You'll probably want to copy/move them into your kernel module directory
(for example: <code>/lib/modules/2.4.18-14/kernel/drivers/char/drm/</code>).
</p>
<h2>2.2 Compiling the Mesa drivers</h2>
<p>
Begin by editing the <code>Mesa/configs/default</code> file to set
the <code>DRM_SOURCE_PATH</code> variable.
Set it to the location where the DRM module sources are located.
For example, if your current directory in step 2.1 was <code>/home/fred/</code>
set DRM_SOURCE_PATH to <code>/home/fred/drm</code>
</p>
<p>
Next, assuming you're starting with a fresh Mesa CVS checkout,
do the following:
Compile Mesa with the 'linux-solo' configuration:
</p>
<pre>
make linux-solo
</pre>
<p>
If you previously built the source tree, run <code>make realclean</code>
first to remove the old object files.
When complete you should have the following:
</p>
<p>
When this is finished, check the <code>Mesa/lib/</code> directory
to verify that the following files were made:
</p>
<ul>
<li><code>libGL.so.1.2</code> - the client-side OpenGL library
(and a few symlinks to it).
<li><code>libGLU.so.1.1</code> - the GLU library (and a few symlinks to it).
<li><code>libglut.so.3.7</code> - the GLUT library (and a few symlinks to it).
<li><code>mga_dri.so</code> - DRI driver for Matrox G200/G400 cards.
<li><code>r128_dri.so</code> - DRI driver for ATI Rage 128 cards.
<li><code>r200_dri.so</code> - DRI driver for ATI R200 Radeon cards.
<li><code>radeon_dri.so</code> - DRI driver for original ATI Radeon cards.
<li><code>i810_dri.so</code> - DRI driver for Intel i810/i815 chips.
<li><code>i830_dri.so</code> - DRI driver for Intel i830/i845 chips.
<li><code>mga_dri.so</code> - DRI driver for Matrox G200/G400 cards.
<li><code>sis_dri.so</code> - DRI driver for SIS cards.
<li><code>tdfx_dri.so</code> - DRI driver for 3dfx Voodoo 3/4/5 cards.
<li><code>gamma_dri.so</code> - DRI driver for 3Dlabs gamma cards.
<li><code>fb_dri.so</code> - software-only fbdev driver.
<li><code>miniglx.conf</code> - configuration file for the MiniGLX interface
<li>lib/libGL.so - the GL library which applications link with
<li>lib/*_dri_so - DRI drivers
<li>lib/miniglx.conf - sample MiniGLX config file
<li>progs/miniglx/* - several MiniGLX sample programs
</ul>
<h1>3. Using fbdev/DRI</h1>
<p>
If XFree86 is currently running, exit/stop the X server so you're
working from the console.
If an X server currently running, exit/stop it so you're working from
the console.
</p>
@@ -175,12 +91,23 @@ working from the console.
<p>
You'll need to load the kernel modules specific to your graphics hardware.
Typically, this consists of the agpgart module, an fbdev driver module
and the DRM kernel module (from step 2.1).
and the DRM kernel module.
</p>
<p>
As root, the kernel modules can be loaded as follows:
</p>
<p>
If you have Intel i915/i945 hardware:
</p>
<pre>
modprobe agpgart # the AGP GART module
modprobe intelfb # the Intel fbdev driver
modprobe i915 # the i915/945 DRI kernel module
</pre>
<p>
If you have ATI Radeon/R200 hardware, run as root:
If you have ATI Radeon/R200 hardware:
</p>
<pre>
modprobe agpgart # the AGP GART module
@@ -189,7 +116,7 @@ If you have ATI Radeon/R200 hardware, run as root:
</pre>
<p>
If you have ATI Rage 128 hardware, run as root:
If you have ATI Rage 128 hardware:
</p>
<pre>
modprobe agpgart # the AGP GART module
@@ -198,7 +125,7 @@ If you have ATI Rage 128 hardware, run as root:
</pre>
<p>
If you have Matrox G200/G400 hardware, run as root:
If you have Matrox G200/G400 hardware:
</p>
<pre>
modprobe agpgart # the AGP GART module
@@ -207,37 +134,46 @@ If you have Matrox G200/G400 hardware, run as root:
</pre>
<p>
Then run <code>lsmod</code> to be sure the modules are loaded.
For a Radeon card, you should see something like this:
To verify that the agpgart, fbdev and drm modules are loaded:
</p>
<pre>
Module Size Used by Not tainted
radeon 110308 0 (unused)
radeonfb 21900 0 (unused)
agpgart 43072 1
ls -l /dev/agpgart /dev/fb* /dev/dri
</pre>
<p>
Alternately, use lsmod to inspect the currently installed modules.
If you have problems, look at the output of dmesg.
</p>
<h2>3.2 Configuration File</h2>
<p>
The <code>Mesa/lib/miniglx.conf</code> file should be installed
in <code>/etc/</code>.
Copy the sample miniglx.conf to /etc/miniglx.conf and review/edit its contents.
Alternately, the MINIGLX_CONF environment variable can be used to
indicate the location of miniglx.conf
</p>
<p>
Edit <code>/etc/miniglx.conf</code> to be sure it's set up correctly
for your hardware.
Comments in the file explain the options.
To determine the pciBusID value, run lspci and examine the output.
For example:
</p>
<pre>
/sbin/lspci:
00:02.0 VGA compatible controller: Intel Corporation 82915G/GV/910GL Express Chipset Family Graphics Controller (rev 04)
</pre>
<p>
00:02.0 indicates that pciBusID should be PCI:0:2:0
</p>
<h2>3.3 Running fbdev/DRI Programs</h2>
<p>
Make sure your LD_LIBRARY_PATH environment variable is set to the
<code>Mesa/lib/</code> directory.
location of the libGL.so library. You may need to append other paths
to LD_LIBRARY_PATH if libpciaccess.so is in a non-standard location,
for example.
</p>
<p>
@@ -245,7 +181,7 @@ Change to the <code>Mesa/progs/miniglx/</code> directory and
start the sample_server program in the background:
</p>
<pre>
./sample_server &
./sample_server &amp;
</pre>
<p>
@@ -268,27 +204,24 @@ them from a remote shell so that you can stop them with ctrl-C.
<h1>4.0 Troubleshooting</h1>
<p>
<ol>
<li>
If you try to run miniglxtest and get the following:
</p>
<br>
<pre>
[miniglx] failed to probe chipset
connect: Connection refused
server connection lost
</pre>
<p>
It means that the sample_server process is not running.
</p>
<br>
<br>
</li>
</ol>
<h1>5.0 Programming Information</h1>
<p>
The full OpenGL API is available with fbdev/DRI.
</p>
<p>
OpenGL/Mesa is interfaced to fbdev via the <a href="MiniGLX.html">MiniGLX</a>
interface.

View File

@@ -128,10 +128,15 @@ specification as well as the GL_ARB_vertex_program and
GL_ARB_fragment_program extensions.
</p>
<p>
June 2007: Mesa 7.0 is released, implementing the OpenGL 2.1 specification
and OpenGL Shading Language.
</p>
<p>
Ongoing: Mesa is used as the core of many hardware OpenGL drivers for
the XFree86 X.org X servers within the
the XFree86 and X.org X servers within the
<A href="http://dri.freedesktop.org/" target="_parent">DRI project</A>.
I continue to enhance Mesa with new extensions and features.
</p>
@@ -141,9 +146,16 @@ I continue to enhance Mesa with new extensions and features.
<H1>Major Versions</H1>
<p>
This is a summary of the major versions of Mesa. Note that Mesa's major
version number tracks OpenGL's minor version number (+1).
Work is underway to implement the OpenGL 2.0 specification.
This is a summary of the major versions of Mesa.
Mesa's major version number has been incremented whenever a new version
of the OpenGL specification is implemented.
</p>
<H2>Version 7.x features</H2>
<p>
Version 7.x of Mesa implements the OpenGL 2.1 API. The main feature
of OpenGL 2.x is the OpenGL Shading Language.
</p>

View File

@@ -11,6 +11,13 @@
<H1>News</H1>
<h2>June 22, 2007</h2>
<p>
<a href="relnotes-7.0.html">Mesa 7.0</a> is released.
This is a stable release featuring OpenGL 2.1 support.
</p>
<h2>April 27, 2007</h2>
<p>
<a href="relnotes-6.5.3.html">Mesa 6.5.3</a> is released.

View File

@@ -18,7 +18,15 @@ Mesa 7.0 is expected to follow shortly.
<h2>MD5 checksums</h2>
<pre>
TBD
39f33ea64e34e2d5b20640b008b57649 MesaLib-6.5.3.tar.gz
46359457147c469745f24b5074a186f0 MesaLib-6.5.3.tar.bz2
a8946fa861634ce15971396f47992c41 MesaLib-6.5.3.zip
08e26948d57eaca74d02a530b2d8106e MesaDemos-6.5.3.tar.gz
8af91773ab2653fe537499676b05f2e8 MesaDemos-6.5.3.tar.bz2
783f81b171bf89b0929abc894efd25a6 MesaDemos-6.5.3.zip
9467d415388fe1ad82991fb20704b812 MesaGLUT-6.5.3.tar.gz
360843e46b7ebb6909290b023f9b26fa MesaGLUT-6.5.3.tar.bz2
7686065e5c15a30de08a1610860b6840 MesaGLUT-6.5.3.zip
</pre>

85
docs/relnotes-7.0.html Normal file
View File

@@ -0,0 +1,85 @@
<HTML>
<TITLE>Mesa Release Notes</TITLE>
<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
<BODY>
<body bgcolor="#eeeeee">
<H1>Mesa 7.0 Release Notes / June 22, 2007</H1>
<p>
Mesa 7.0 is a stable release, featuring OpenGL 2.1 API support.
A number of bugs have been fixed since the 6.5.3 release.
</p>
<h2>MD5 checksums</h2>
<pre>
TBD
</pre>
<h2>New features</h2>
<ul>
<li>OpenGL 2.0 and 2.1 API support.
</ul>
<h2>Bug fixes</h2>
<ul>
<li>Fixed a few fog-related bugs.
<li>Fixed broken GLSL mix() function.
<li>Fixed broken GLSL exp() functions.
<li>Fixed GLSL mod4(vec4, vec4) bug.
<li>Implemented GLSL asin(), acos(), atan() functions.
<li>Fixed an R300 driver bug that caused Xorg composite manager to crash
<li>Fixed R300 vertex program/matrix bug (10848)
<li>GLSL dFdx() and dFdy() work for fragment program inputs now (texcoords)
<li>Specifying an invalid texture unit as a sampler could lead to a crash
<li>The GLX protocol request for glXDestroyPBuffer() was incorrect (bug 10983)
<li>ARB vp state.light[n].half value was incorrect (bug 10987)
<li>Fixed a positional light source bug (bug 11009)
<li>Fixed point size attenuation problem (bug 11042)
<li>glPopAttrib didn't restore texture object's LOD bias (bug 11049)
<li>Fixed a TLS / TEXTREL problem (bug 7459)
</ul>
<h2>Internal code changes</h2>
<ul>
<li>Some texture code consolidation and simplifiction (Ian Romanick)
<li>R300 driver clean-ups.
</ul>
<h2>To Do (someday) items</h2>
<ul>
<li>Switch to freeglut
<li>Fix linux-glide target/driver.
<li>Improved lambda and derivative calculation for frag progs.
</ul>
<h2>Driver Status</h2>
<pre>
Driver Status
---------------------- ----------------------
DRI drivers varies with the driver
XMesa/GLX (on Xlib) implements OpenGL 2.1
OSMesa (off-screen) implements OpenGL 2.1
Windows/Win32 implements OpenGL 2.1
Glide (3dfx Voodoo1/2) implements OpenGL 1.3
SVGA unsupported
Wind River UGL unsupported
DJGPP unsupported
GGI unsupported
BeOS unsupported
Allegro unsupported
D3D unsupported
</pre>
</body>
</html>

View File

@@ -20,6 +20,7 @@ The release notes summarize what's new or changed in each Mesa release.
</p>
<UL>
<LI><A HREF="relnotes-7.0.html">7.0 release notes</A>
<LI><A HREF="relnotes-6.5.3.html">6.5.3 release notes</A>
<LI><A HREF="relnotes-6.5.2.html">6.5.2 release notes</A>
<LI><A HREF="relnotes-6.5.1.html">6.5.1 release notes</A>

View File

@@ -1,17 +1,18 @@
<HTML>
<TITLE>Mesa Subset</TITLE>
<TITLE>Mesa Subset Driver</TITLE>
<link rel="stylesheet" type="text/css" href="mesa.css"></head>
<BODY>
<H1>Mesa Subset</H1>
<H1>Mesa Subset Driver</H1>
<p>
In 2002/2003 Tungsten Graphics was contracted to develop a subset Mesa/Radeon
driver for an embedded environment. The result is a reduced-size DRI driver
for the ATI R200 chip, for use with Linux fbdev rather than XFree86.
for the ATI R200 chip, for use with
<a href="fbdev-dri.html">fbdev/DRI environment</a>.
</p>
<p>
@@ -19,15 +20,5 @@ The specification for this subset can be found
<a href="subset-A.html">here</a>.
</p>
<p>
The <a href="MiniGLX.html">MiniGLX specification</a> describes the
interface between fbdev and Mesa.
</p>
<p>
More info to come...
</p>
</BODY>
</HTML>

View File

@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
* Version: 6.5.1
* Version: 7.0
*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2007 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"),

View File

@@ -17,7 +17,7 @@ message:
subdirs:
@for dir in $(SUBDIRS) ; do \
if [ -d $$dir ] ; then \
(cd $$dir ; $(MAKE)) || exit 1 ; \
(cd $$dir && $(MAKE)) || exit 1 ; \
fi \
done
@@ -27,6 +27,6 @@ install:
clean:
@for dir in $(SUBDIRS) tests ; do \
if [ -d $$dir ] ; then \
(cd $$dir ; $(MAKE) clean) ; \
(cd $$dir && $(MAKE) clean) ; \
fi \
done

View File

@@ -5,17 +5,12 @@ include $(TOP)/configs/current
INCDIR = $(TOP)/include
OSMESA_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lOSMesa -lGLU -lGL $(APP_LIB_DEPS)
OSMESA16_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lOSMesa16 -lGLU -lGL $(APP_LIB_DEPS)
OSMESA32_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lOSMesa32 -lGLU -lGL $(APP_LIB_DEPS)
LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
PROGS = \
brick \
bump \
deriv \
mandelbrot \
noise \
toyball \

319
progs/glsl/deriv.c Normal file
View File

@@ -0,0 +1,319 @@
/**
* Test OpenGL 2.0 dx/dy functions for texcoords.
* Brian Paul
* 2 May 2007
*
* NOTE: resize the window to observe how the partial derivatives of
* the texcoords change.
*/
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GL/gl.h>
#include <GL/glut.h>
#include <GL/glext.h>
#include "extfuncs.h"
static char *FragProgFile = NULL;
static char *VertProgFile = NULL;
static GLuint fragShader;
static GLuint vertShader;
static GLuint program;
static GLuint SphereList, RectList, CurList;
static GLint win = 0;
static GLboolean anim = GL_TRUE;
static GLfloat xRot = 0.0f, yRot = 0.0f;
static void
Redisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
glRotatef(yRot, 0.0f, 1.0f, 0.0f);
glCallList(CurList);
glPopMatrix();
glutSwapBuffers();
}
static void
Idle(void)
{
yRot = glutGet(GLUT_ELAPSED_TIME) * 0.1;
glutPostRedisplay();
}
static void
Reshape(int width, int height)
{
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -15.0f);
}
static void
CleanUp(void)
{
glDeleteShader_func(fragShader);
glDeleteShader_func(vertShader);
glDeleteProgram_func(program);
glutDestroyWindow(win);
}
static void
Key(unsigned char key, int x, int y)
{
(void) x;
(void) y;
switch(key) {
case ' ':
case 'a':
anim = !anim;
if (anim)
glutIdleFunc(Idle);
else
glutIdleFunc(NULL);
break;
case 'o':
if (CurList == SphereList)
CurList = RectList;
else
CurList = SphereList;
break;
case 27:
CleanUp();
exit(0);
break;
}
glutPostRedisplay();
}
static void
SpecialKey(int key, int x, int y)
{
const GLfloat step = 3.0f;
(void) x;
(void) y;
switch(key) {
case GLUT_KEY_UP:
xRot -= step;
break;
case GLUT_KEY_DOWN:
xRot += step;
break;
case GLUT_KEY_LEFT:
yRot -= step;
break;
case GLUT_KEY_RIGHT:
yRot += step;
break;
}
glutPostRedisplay();
}
static void
MakeSphere(void)
{
GLUquadricObj *obj = gluNewQuadric();
SphereList = glGenLists(1);
gluQuadricTexture(obj, GL_TRUE);
glNewList(SphereList, GL_COMPILE);
gluSphere(obj, 2.0f, 30, 15);
glEndList();
}
static void
MakeRect(void)
{
RectList = glGenLists(1);
glNewList(RectList, GL_COMPILE);
glBegin(GL_POLYGON);
glTexCoord2f(0, 0); glVertex2f(-2, -2);
glTexCoord2f(1, 0); glVertex2f( 2, -2);
glTexCoord2f(1, 1); glVertex2f( 2, 2);
glTexCoord2f(0, 1); glVertex2f(-2, 2);
glEnd();
glEndList();
}
static void
LoadAndCompileShader(GLuint shader, const char *text)
{
GLint stat;
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
glCompileShader_func(shader);
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
if (!stat) {
GLchar log[1000];
GLsizei len;
glGetShaderInfoLog_func(shader, 1000, &len, log);
fprintf(stderr, "fslight: problem compiling shader:\n%s\n", log);
exit(1);
}
}
/**
* Read a shader from a file.
*/
static void
ReadShader(GLuint shader, const char *filename)
{
const int max = 100*1000;
int n;
char *buffer = (char*) malloc(max);
FILE *f = fopen(filename, "r");
if (!f) {
fprintf(stderr, "fslight: Unable to open shader file %s\n", filename);
exit(1);
}
n = fread(buffer, 1, max, f);
printf("fslight: read %d bytes from shader file %s\n", n, filename);
if (n > 0) {
buffer[n] = 0;
LoadAndCompileShader(shader, buffer);
}
fclose(f);
free(buffer);
}
static void
CheckLink(GLuint prog)
{
GLint stat;
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
if (!stat) {
GLchar log[1000];
GLsizei len;
glGetProgramInfoLog_func(prog, 1000, &len, log);
fprintf(stderr, "Linker error:\n%s\n", log);
}
}
static void
Init(void)
{
static const char *fragShaderText =
"void main() {\n"
" gl_FragColor = abs(dFdy(gl_TexCoord[0])) * 50.0;\n"
" // gl_FragColor = gl_TexCoord[0];\n"
"}\n";
static const char *vertShaderText =
"void main() {\n"
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
" gl_TexCoord[0] = gl_MultiTexCoord0;\n"
"}\n";
const char *version;
version = (const char *) glGetString(GL_VERSION);
if (version[0] != '2' || version[1] != '.') {
printf("This program requires OpenGL 2.x, found %s\n", version);
exit(1);
}
GetExtensionFuncs();
fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
if (FragProgFile)
ReadShader(fragShader, FragProgFile);
else
LoadAndCompileShader(fragShader, fragShaderText);
vertShader = glCreateShader_func(GL_VERTEX_SHADER);
if (VertProgFile)
ReadShader(vertShader, VertProgFile);
else
LoadAndCompileShader(vertShader, vertShaderText);
program = glCreateProgram_func();
glAttachShader_func(program, fragShader);
glAttachShader_func(program, vertShader);
glLinkProgram_func(program);
CheckLink(program);
glUseProgram_func(program);
/*assert(glGetError() == 0);*/
glClearColor(0.3f, 0.3f, 0.3f, 0.0f);
glEnable(GL_DEPTH_TEST);
MakeSphere();
MakeRect();
CurList = SphereList;
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
assert(glIsProgram_func(program));
assert(glIsShader_func(fragShader));
assert(glIsShader_func(vertShader));
glColor3f(1, 0, 0);
}
static void
ParseOptions(int argc, char *argv[])
{
int i;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-fs") == 0) {
FragProgFile = argv[i+1];
}
else if (strcmp(argv[i], "-vs") == 0) {
VertProgFile = argv[i+1];
}
}
}
int
main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowPosition( 0, 0);
glutInitWindowSize(200, 200);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
win = glutCreateWindow(argv[0]);
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
glutSpecialFunc(SpecialKey);
glutDisplayFunc(Redisplay);
if (anim)
glutIdleFunc(Idle);
ParseOptions(argc, argv);
Init();
glutMainLoop();
return 0;
}

View File

@@ -1,5 +1,3 @@
/* $Id: miniglxtest.c,v 1.3 2004/03/25 14:58:39 brianp Exp $ */
/*
* Test the mini GLX interface.
*/
@@ -7,6 +5,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <GL/gl.h>
#define USE_MINI_GLX 1
@@ -16,90 +15,86 @@
#include <GL/glx.h>
#endif
#define FRONTBUFFER 1
#define NR 6
#define DO_SLEEPS 1
#define NR_DISPLAYS 2
static GLXContext ctx;
GLXContext ctx;
static GLuint NumFrames = 100;
static GLuint NumDisplays = 1;
static GLboolean Texture = GL_FALSE;
static GLboolean SingleBuffer = GL_FALSE;
static GLboolean Sleeps = GL_TRUE;
static void _subset_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
static void
rect(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
{
glBegin( GL_QUADS );
glVertex2f( x1, y1 );
glVertex2f( x2, y1 );
glVertex2f( x2, y2 );
glVertex2f( x1, y2 );
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glColor3f(0, 0, 1); glVertex2f(x1, y1);
glTexCoord2f(1, 0); glColor3f(1, 0, 0); glVertex2f(x2, y1);
glTexCoord2f(1, 1); glColor3f(0, 1, 0); glVertex2f(x2, y2);
glTexCoord2f(0, 1); glColor3f(0, 0, 0); glVertex2f(x1, y2);
glEnd();
}
static void redraw( Display *dpy, Window w, int rot )
static void
redraw(Display *dpy, Window w, int rot)
{
printf("Redraw event\n");
GLfloat a;
#if FRONTBUFFER
glDrawBuffer( GL_FRONT );
#else
/* glDrawBuffer( GL_BACK ); */
#endif
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor( rand()/(float)RAND_MAX,
rand()/(float)RAND_MAX,
rand()/(float)RAND_MAX,
1);
glClear( GL_COLOR_BUFFER_BIT );
#if 1
glColor3f( rand()/(float)RAND_MAX,
rand()/(float)RAND_MAX,
rand()/(float)RAND_MAX );
glPushMatrix();
glRotatef(rot, 0, 0, 1);
glScalef(.5, .5, .5);
_subset_Rectf( -1, -1, 1, 1 );
glRotatef(rot, 0, 0, 1);
glScalef(.5, .5, .5);
for (a = 0.0; a < 360.0; a += 30.0) {
glPushMatrix();
glRotatef(a, 0, 0, 1);
glRotatef(40, 1, 0, 0);
glColor3f(a / 360.0, 1-a/360.0, 0);
rect(0.3, -0.25, 1.5, 0.25);
glPopMatrix();
}
glPopMatrix();
#endif
#if FRONTBUFFER
glFlush();
#else
glXSwapBuffers( dpy, w );
#endif
glFinish();
if (SingleBuffer)
glFlush();
else
glXSwapBuffers(dpy, w);
}
static Window make_rgb_db_window( Display *dpy,
unsigned int width, unsigned int height )
static Window
make_window(Display *dpy, unsigned int width, unsigned int height)
{
int attrib[] = { GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
#if !FRONTBUFFER
GLX_DOUBLEBUFFER,
#endif
None };
int scrnum;
int attrib_single[] = { GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DEPTH_SIZE, 1,
None };
int attrib_double[] = { GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DEPTH_SIZE, 1,
GLX_DOUBLEBUFFER,
None };
int *attrib = SingleBuffer ? attrib_single : attrib_double;
int scrnum = 0;
XSetWindowAttributes attr;
unsigned long mask;
Window root;
Window win;
XVisualInfo *visinfo;
scrnum = 0;
root = RootWindow( dpy, scrnum );
root = RootWindow(dpy, scrnum);
if (!(visinfo = glXChooseVisual( dpy, scrnum, attrib ))) {
if (!(visinfo = glXChooseVisual(dpy, scrnum, attrib))) {
printf("Error: couldn't get an RGB, Double-buffered visual\n");
exit(1);
}
if(!(ctx = glXCreateContext( dpy, visinfo, NULL, True ))) {
if (!(ctx = glXCreateContext(dpy, visinfo, NULL, True))) {
printf("Error: glXCreateContext failed\n");
exit(1);
}
@@ -107,19 +102,19 @@ static Window make_rgb_db_window( Display *dpy,
/* window attributes */
attr.background_pixel = 0;
attr.border_pixel = 0;
attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
attr.event_mask = StructureNotifyMask | ExposureMask;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
win = XCreateWindow( dpy, root, 0, 0, width, height,
win = XCreateWindow(dpy, root, 0, 0, width, height,
0, visinfo->depth, InputOutput,
visinfo->visual, mask, &attr );
visinfo->visual, mask, &attr);
if (!win) {
printf("Error: XCreateWindow failed\n");
exit(1);
}
glXMakeCurrent( dpy, win, ctx );
glXMakeCurrent(dpy, win, ctx);
glViewport(0, 0, width, height);
@@ -127,22 +122,24 @@ static Window make_rgb_db_window( Display *dpy,
}
static void event_loop( Display *dpy, Window win )
static void
event_loop(Display *dpy, Window win)
{
int i;
printf("Hang on... drawing %d frames\n", NR);
for (i = 0; i < NR; i++) {
redraw( dpy, win, i*10 );
if (DO_SLEEPS) {
printf("sleep(1)\n");
sleep(1);
printf("Drawing %d frames\n", NumFrames);
for (i = 0; i < NumFrames; i++) {
redraw(dpy, win, -i*2);
if (Sleeps) {
usleep(20000);
}
}
}
static int foo( void )
static int
runtest(void)
{
Display *dpy;
Window win;
@@ -153,41 +150,121 @@ static int foo( void )
return 1;
}
win = make_rgb_db_window( dpy, 800, 600);
win = make_window(dpy, 800, 600);
srand(getpid());
glShadeModel( GL_FLAT );
glClearColor( 0.5, 0.5, 0.5, 1.0 );
/* init GL state */
glClearColor(0.5, 0.5, 0.5, 1.0);
glEnable(GL_DEPTH_TEST);
if (Texture) {
GLubyte image[16][16][4];
GLint i, j;
for (i = 0; i < 16; i++) {
for (j = 0; j < 16; j++) {
if (((i / 2) ^ (j / 2)) & 1) {
image[i][j][0] = 255;
image[i][j][1] = 255;
image[i][j][2] = 255;
image[i][j][3] = 255;
}
else {
image[i][j][0] = 128;
image[i][j][1] = 128;
image[i][j][2] = 128;
image[i][j][3] = 128;
}
}
}
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0,
GL_RGBA, GL_UNSIGNED_BYTE, image);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glEnable(GL_TEXTURE_2D);
}
if (SingleBuffer) {
glDrawBuffer(GL_FRONT);
glReadBuffer(GL_FRONT);
}
else {
glDrawBuffer(GL_BACK);
}
XMapWindow( dpy, win );
XMapWindow(dpy, win);
/* wait for window to get mapped */
{
XEvent e;
while (1) {
XNextEvent( dpy, &e );
XNextEvent(dpy, &e);
if (e.type == MapNotify && e.xmap.window == win) {
break;
}
}
}
event_loop( dpy, win );
event_loop(dpy, win);
glXDestroyContext( dpy, ctx );
XDestroyWindow( dpy, win );
glXDestroyContext(dpy, ctx);
XDestroyWindow(dpy, win);
XCloseDisplay( dpy );
XCloseDisplay(dpy);
return 0;
}
int main()
static void
usage(void)
{
printf("Usage:\n");
printf(" -f N render N frames (default %d)\n", NumFrames);
printf(" -d N do N display cycles\n");
printf(" -t texturing\n");
printf(" -s single buffering\n");
printf(" -n no usleep() delay\n");
}
static void
parse_args(int argc, char *argv[])
{
int i;
for (i = 0 ; i < NR_DISPLAYS ; i++) {
if (foo() != 0)
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-f") == 0) {
NumFrames = atoi(argv[i + 1]);
i++;
}
else if (strcmp(argv[i], "-d") == 0) {
NumDisplays = atoi(argv[i + 1]);
i++;
}
else if (strcmp(argv[i], "-n") == 0) {
Sleeps = GL_FALSE;
}
else if (strcmp(argv[i], "-s") == 0) {
SingleBuffer = GL_TRUE;
}
else if (strcmp(argv[i], "-t") == 0) {
Texture = GL_TRUE;
}
else {
usage();
exit(1);
}
}
}
int
main(int argc, char *argv[])
{
int i;
parse_args(argc, argv);
for (i = 0; i < NumDisplays; i++) {
if (runtest() != 0)
break;
}

View File

@@ -17,14 +17,14 @@ message:
subdirs:
@for dir in $(SUBDIRS) ; do \
if [ -d $$dir ] ; then \
(cd $$dir ; $(MAKE)) || exit 1 ; \
(cd $$dir && $(MAKE)) || exit 1; \
fi \
done
install:
@for dir in $(SUBDIRS) ; do \
if [ -d $$dir ] ; then \
(cd $$dir ; $(MAKE) install) || exit 1 ; \
(cd $$dir && $(MAKE) install) || exit 1 ; \
fi \
done
@@ -35,6 +35,6 @@ $(TOP)/$(LIB_DIR):
clean:
@for dir in $(SUBDIRS) ; do \
if [ -d $$dir ] ; then \
(cd $$dir ; $(MAKE) clean) ; \
(cd $$dir && $(MAKE) clean) ; \
fi \
done

View File

@@ -90,7 +90,7 @@ int APIENTRY glutCreateWindow (const char *title)
attr.event_mask = StructureNotifyMask | ExposureMask;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
win = XCreateWindow( dpy, root, 0, 0, g_width, g_height,
win = XCreateWindow( dpy, root, g_xpos, g_ypos, g_width, g_height,
0, visinfo->depth, InputOutput,
visinfo->visual, mask, &attr );
if (!win) {

View File

@@ -1,5 +1,4 @@
# Build a subset DRI-based libGL.so library.
# Indirect rendering not supported, etc.
# Build the MiniGLX libGL.so library.
TOP = ../../..
include $(TOP)/configs/current
@@ -29,7 +28,9 @@ INCLUDE_DIRS = \
-I$(TOP)/src/mesa/glapi \
-I$(TOP)/src/glx/x11 \
-I$(TOP)/src/mesa/drivers/dri/common \
`pkg-config --cflags libdrm`
$(LIBDRM_CFLAGS) \
$(PCIACCESS_CFLAGS)
##### RULES #####
@@ -43,16 +44,20 @@ INCLUDE_DIRS = \
##### TARGETS #####
default: depend $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
default: depend $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/miniglx.conf
# Make libGL
$(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) Makefile
$(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' \
@ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' \
-major 1 -minor 2 $(MKLIB_OPTIONS) \
-install $(TOP)/$(LIB_DIR) $(GL_LIB_DEPS) $(OBJECTS) `/usr/bin/pkg-config --libs libdrm` `/usr/bin/pkg-config --libs pciaccess`
rm -f $(TOP)/$(LIB_DIR)/miniglx.conf
install example.miniglx.conf $(TOP)/$(LIB_DIR)/miniglx.conf
-install $(TOP)/$(LIB_DIR) $(GL_LIB_DEPS) $(OBJECTS) \
$(LIBDRM_LIB) $(PCIACCESS_LIB)
# install sample miniglx.conf
$(TOP)/$(LIB_DIR)/miniglx.conf:
$(INSTALL) example.miniglx.conf $(TOP)/$(LIB_DIR)/miniglx.conf
drmtest: xf86drm.o drmtest.o

View File

@@ -1528,8 +1528,8 @@ XCreateWindow( Display *dpy, Window parent, int x, int y,
}
/* init other per-window fields */
win->x = 0;
win->y = 0;
win->x = x;
win->y = y;
win->w = width;
win->h = height;
win->visual = visual; /* ptr assignment */
@@ -1537,7 +1537,7 @@ XCreateWindow( Display *dpy, Window parent, int x, int y,
win->bytesPerPixel = dpy->driverContext.cpp;
win->rowStride = dpy->driverContext.shared.virtualWidth * win->bytesPerPixel;
win->size = win->rowStride * height;
win->frontStart = dpy->driverContext.FBAddress;
win->frontStart = dpy->driverContext.FBAddress + (win->rowStride * win->x) + (win->y * win->bytesPerPixel);
win->frontBottom = (GLubyte *) win->frontStart + (height-1) * win->rowStride;
/* This is incorrect: the hardware driver could put the backbuffer

View File

@@ -150,7 +150,7 @@ DestroyPbuffer( Display * dpy, GLXDrawable drawable )
if ( (priv->majorVersion > 1) || (priv->minorVersion >= 3) ) {
xGLXDestroyPbufferReq * req;
GetReqExtra( GLXDestroyPbuffer, 4, req );
GetReq( GLXDestroyPbuffer, req );
req->reqType = opcode;
req->glxCode = X_GLXDestroyPbuffer;
req->pbuffer = (GLXPbuffer) drawable;

View File

@@ -1667,7 +1667,7 @@ __glXGetArrayType( const __GLXattribute * const state,
key, index );
if ( a != NULL ) {
*dest = (GLintptr) a->enabled;
*dest = (GLintptr) a->data_type;
}
return (a != NULL);

View File

@@ -14,21 +14,25 @@ $(TOP)/$(LIB_DIR):
subdirs:
echo $(DRI_DIRS)
@for dir in $(DRI_DIRS) ; do \
echo $$dir ; \
(cd $$dir && $(MAKE)) || exit 1; \
if [ -d $$dir ] ; then \
(cd $$dir && $(MAKE)) || exit 1 ; \
fi \
done
install:
@for dir in $(DRI_DIRS) ; do \
(cd $$dir && $(MAKE) install) || exit 1; \
if [ -d $$dir ] ; then \
(cd $$dir && $(MAKE) install) || exit 1 ; \
fi \
done
clean:
@for dir in $(DRI_DIRS) ; do \
(cd $$dir && $(MAKE) clean) ; \
if [ -d $$dir ] ; then \
(cd $$dir && $(MAKE) clean ; \
fi \
done
-rm -f common/*.o

View File

@@ -25,11 +25,13 @@ OBJECTS = $(C_SOURCES:.c=.o) \
$(ASM_SOURCES:.S=.o)
else
# miniglx
WINOBJ=
WINLIB=-L$(MESA)/src/glx/mini
MINIGLX_INCLUDES = -I$(TOP)/src/glx/mini
INCLUDES = $(MINIGLX_INCLUDES) \
$(SHARED_INCLUDES)
$(SHARED_INCLUDES) \
$(PCIACCESS_CFLAGS)
OBJECTS = $(C_SOURCES:.c=.o) \
$(MINIGLX_SOURCES:.c=.o) \
@@ -54,7 +56,8 @@ SHARED_INCLUDES = \
-I$(TOP)/src/mesa/swrast_setup \
-I$(TOP)/src/egl/main \
-I$(TOP)/src/egl/drivers/dri \
`pkg-config --cflags libdrm`
$(LIBDRM_CFLAGS)
##### RULES #####
@@ -70,11 +73,6 @@ SHARED_INCLUDES = \
default: depend symlinks $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME)
#$(TOP)/$(LIB_DIR)/$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(WINOBJ) Makefile
# @echo BUILDING FOR: $(WINDOW_SYSTEM)
# $(TOP)/bin/mklib -o $(LIBNAME) -noprefix -install $(TOP)/$(LIB_DIR) \
# $(WINLIB) $(LIB_DEPS) $(WINOBJ) $(MESA_MODULES) $(OBJECTS)
$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(WINOBJ) Makefile $(TOP)/src/mesa/drivers/dri/Makefile.template
$(TOP)/bin/mklib -noprefix -o $@ \
$(OBJECTS) $(MESA_MODULES) $(WINOBJ) $(DRI_LIB_DEPS)
@@ -84,9 +82,6 @@ $(TOP)/$(LIB_DIR)/$(LIBNAME): $(LIBNAME)
$(INSTALL) $(LIBNAME) $(TOP)/$(LIB_DIR)
# Run 'make depend' to update the dependencies if you change
# what's included by any source file.
depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
touch depend
$(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) \
@@ -103,8 +98,10 @@ clean:
-rm -f *.o */*.o *~ *.so *~ server/*.o $(SYMLINKS)
-rm -f depend depend.bak
install: $(LIBNAME)
$(INSTALL) -d $(DRI_DRIVER_INSTALL_DIR)
$(INSTALL) -m 755 $(LIBNAME) $(DRI_DRIVER_INSTALL_DIR)
include depend

View File

@@ -172,12 +172,8 @@ static void i915LayoutTextureImages( i915ContextPtr i915,
t->intel.image[0][i].offset = total_height * pitch;
t->intel.image[0][i].internalFormat = baseImage->_BaseFormat;
if (t->intel.image[0][i].image->IsCompressed)
{
if (t->intel.image[0][i].image->Height > 4)
total_height += t->intel.image[0][i].image->Height/4;
else
total_height += 1;
if (t->intel.image[0][i].image->IsCompressed) {
total_height += (t->intel.image[0][i].image->Height + 3) / 4;
}
else
total_height += MAX2(2, t->intel.image[0][i].image->Height);

View File

@@ -634,11 +634,32 @@ static void intelUploadTexImage( intelContextPtr intel,
image->Height);
}
else if (image->IsCompressed) {
GLuint row_len = image->Width * 2;
GLuint row_len = 0;
GLubyte *dst = (GLubyte *)(t->BufAddr + offset);
GLubyte *src = (GLubyte *)image->Data;
GLuint j;
/* must always copy whole blocks (8/16 bytes) */
switch (image->InternalFormat) {
case GL_COMPRESSED_RGB_FXT1_3DFX:
case GL_COMPRESSED_RGBA_FXT1_3DFX:
case GL_RGB_S3TC:
case GL_RGB4_S3TC:
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
row_len = (image->Width * 2 + 7) & ~7;
break;
case GL_RGBA_S3TC:
case GL_RGBA4_S3TC:
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
row_len = (image->Width * 4 + 15) & ~15;
break;
default:
fprintf(stderr,"Internal Compressed format not supported %d\n", image->InternalFormat);
break;
}
if (INTEL_DEBUG & DEBUG_TEXTURE)
fprintf(stderr,
"Upload image %dx%dx%d offset %xm row_len %x "
@@ -646,30 +667,11 @@ static void intelUploadTexImage( intelContextPtr intel,
image->Width, image->Height, image->Depth, offset,
row_len, t->Pitch, t->depth_pitch);
switch (image->InternalFormat) {
case GL_COMPRESSED_RGB_FXT1_3DFX:
case GL_COMPRESSED_RGBA_FXT1_3DFX:
case GL_RGB_S3TC:
case GL_RGB4_S3TC:
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
for (j = 0 ; j < image->Height/4 ; j++, dst += (t->Pitch)) {
__memcpy(dst, src, row_len );
src += row_len;
}
break;
case GL_RGBA_S3TC:
case GL_RGBA4_S3TC:
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
for (j = 0 ; j < image->Height/4 ; j++, dst += (t->Pitch)) {
__memcpy(dst, src, (image->Width*4) );
src += image->Width*4;
}
break;
default:
fprintf(stderr,"Internal Compressed format not supported %d\n", image->InternalFormat);
break;
if (row_len) {
for (j = 0 ; j < (image->Height + 3)/4 ; j++, dst += (t->Pitch)) {
__memcpy(dst, src, row_len );
src += row_len;
}
}
}
/* Time for another vtbl entry:

View File

@@ -455,12 +455,14 @@ static unsigned long AllocFromAGP(const DRIDriverContext *ctx, I830Rec *pI830, l
}
unsigned long
I830AllocVidMem(const DRIDriverContext *ctx, I830Rec *pI830, I830MemRange *result, I830MemPool *pool, long size, unsigned long alignment, int flags)
I830AllocVidMem(const DRIDriverContext *ctx, I830Rec *pI830,
I830MemRange *result, I830MemPool *pool, long size,
unsigned long alignment, int flags)
{
int ret;
unsigned long ret;
if (!result)
return 0;
if (!result)
return 0;
/* Make sure these are initialised. */
result->Size = 0;
@@ -470,16 +472,15 @@ I830AllocVidMem(const DRIDriverContext *ctx, I830Rec *pI830, I830MemRange *resul
return 0;
}
if (pool->Free.Size < size)
return AllocFromAGP(ctx, pI830, size, alignment, result);
else
{
ret = AllocFromPool(ctx, pI830, result, pool, size, alignment, flags);
if (ret==0)
return AllocFromAGP(ctx, pI830, size, alignment, result);
return ret;
if (pool->Free.Size < size) {
ret = AllocFromAGP(ctx, pI830, size, alignment, result);
}
else {
ret = AllocFromPool(ctx, pI830, result, pool, size, alignment, flags);
if (ret == 0)
ret = AllocFromAGP(ctx, pI830, size, alignment, result);
}
return ret;
}
static Bool BindAgpRange(const DRIDriverContext *ctx, I830MemRange *mem)

View File

@@ -161,11 +161,9 @@ i915_miptree_layout(struct intel_mipmap_tree * mt)
if (mt->compressed)
img_height = MAX2(1, height / 4);
else
img_height = MAX2(2, height);
img_height = (MAX2(2, height) + 1) & ~1;
mt->total_height += img_height;
mt->total_height += 1;
mt->total_height &= ~1;
width = minify(width);
height = minify(height);

View File

@@ -105,6 +105,8 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
{
struct gl_texture_object *tObj = intel->ctx.Texture.Unit[unit]._Current;
struct intel_texture_object *intelObj = intel_texture_object(tObj);
int comp_byte = 0;
int cpp;
GLuint face, i;
GLuint nr_faces = 0;
@@ -148,6 +150,12 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
intel_miptree_reference(&intelObj->mt, firstImage->mt);
}
if (firstImage->base.IsCompressed) {
comp_byte = intel_compressed_num_bytes(firstImage->base.TexFormat->MesaFormat);
cpp = comp_byte;
}
else cpp = firstImage->base.TexFormat->TexelBytes;
/* Check tree can hold all active levels. Check tree matches
* target, imageFormat, etc.
*
@@ -165,7 +173,7 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
intelObj->mt->width0 != firstImage->base.Width ||
intelObj->mt->height0 != firstImage->base.Height ||
intelObj->mt->depth0 != firstImage->base.Depth ||
intelObj->mt->cpp != firstImage->base.TexFormat->TexelBytes ||
intelObj->mt->cpp != cpp ||
intelObj->mt->compressed != firstImage->base.IsCompressed)) {
intel_miptree_release(intel, &intelObj->mt);
}
@@ -174,10 +182,6 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
/* May need to create a new tree:
*/
if (!intelObj->mt) {
int comp_byte = 0;
if (firstImage->base.IsCompressed)
comp_byte = intel_compressed_num_bytes(firstImage->base.TexFormat->MesaFormat);
intelObj->mt = intel_miptree_create(intel,
intelObj->base.Target,
firstImage->base.InternalFormat,
@@ -186,8 +190,7 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
firstImage->base.Width,
firstImage->base.Height,
firstImage->base.Depth,
firstImage->base.TexFormat->
TexelBytes,
cpp,
comp_byte);
}

View File

@@ -483,12 +483,14 @@ static unsigned long AllocFromAGP(const DRIDriverContext *ctx, I830Rec *pI830, l
}
unsigned long
I830AllocVidMem(const DRIDriverContext *ctx, I830Rec *pI830, I830MemRange *result, I830MemPool *pool, long size, unsigned long alignment, int flags)
I830AllocVidMem(const DRIDriverContext *ctx, I830Rec *pI830,
I830MemRange *result, I830MemPool *pool, long size,
unsigned long alignment, int flags)
{
int ret;
unsigned long ret;
if (!result)
return 0;
if (!result)
return 0;
/* Make sure these are initialised. */
result->Size = 0;
@@ -498,16 +500,15 @@ I830AllocVidMem(const DRIDriverContext *ctx, I830Rec *pI830, I830MemRange *resul
return 0;
}
if (pool->Free.Size < size)
return AllocFromAGP(ctx, pI830, size, alignment, result);
else
{
ret = AllocFromPool(ctx, pI830, result, pool, size, alignment, flags);
if (ret==0)
return AllocFromAGP(ctx, pI830, size, alignment, result);
return ret;
if (pool->Free.Size < size) {
ret = AllocFromAGP(ctx, pI830, size, alignment, result);
}
else {
ret = AllocFromPool(ctx, pI830, result, pool, size, alignment, flags);
if (ret == 0)
ret = AllocFromAGP(ctx, pI830, size, alignment, result);
}
return ret;
}
static Bool BindAgpRange(const DRIDriverContext *ctx, I830MemRange *mem)
@@ -895,31 +896,6 @@ I830DRIUnmapScreenRegions(const DRIDriverContext *ctx, I830Rec *pI830, drmI830Sa
}
}
#if 0
static void
I830InitTextureHeap(const DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea)
{
/* Start up the simple memory manager for agp space */
drmI830MemInitHeap drmHeap;
drmHeap.region = I830_MEM_REGION_AGP;
drmHeap.start = 0;
drmHeap.size = sarea->tex_size;
if (drmCommandWrite(ctx->drmFD, DRM_I830_INIT_HEAP,
&drmHeap, sizeof(drmHeap))) {
fprintf(stderr,
"[drm] Failed to initialized agp heap manager\n");
} else {
fprintf(stderr,
"[drm] Initialized kernel agp heap manager, %d\n",
sarea->tex_size);
I830SetParam(ctx, I830_SETPARAM_TEX_LRU_LOG_GRANULARITY,
sarea->log_tex_granularity);
}
}
#endif
static Bool
I830DRIDoMappings(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea)
{
@@ -943,9 +919,6 @@ I830DRIDoMappings(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea)
I830DRIMapScreenRegions(ctx, pI830, sarea);
SetupDRIMM(ctx, pI830);
#if 0
I830InitTextureHeap(ctx, pI830, sarea);
#endif
if (ctx->pciDevice != PCI_CHIP_845_G &&
ctx->pciDevice != PCI_CHIP_I830_M) {
I830SetParam(ctx, I830_SETPARAM_USE_MI_BATCHBUFFER_START, 1 );

View File

@@ -34,6 +34,7 @@
#include "brw_state.h"
#include "brw_defines.h"
#include "brw_util.h"
#include "macros.h"
#include "enums.h"
static void upload_cc_vp( struct brw_context *brw )

View File

@@ -46,7 +46,7 @@
#include "tnl/tnl.h"
#include "vbo/vbo_context.h"
#include "swrast/swrast.h"

View File

@@ -74,7 +74,7 @@ void i945_miptree_layout_2d( struct intel_mipmap_tree *mt )
GLuint img_height;
intel_miptree_set_level_info(mt, level, 1, x, y, width,
mt->compressed ? height/4 : height, 1);
height, 1);
if (mt->compressed)
img_height = MAX2(1, height/4);

View File

@@ -679,7 +679,6 @@ r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
newCtx->dri.drawable = driDrawPriv;
r200SetCliprects(newCtx);
r200UpdateWindow( newCtx->glCtx );
r200UpdateViewportOffset( newCtx->glCtx );
}

View File

@@ -1,3 +1,4 @@
radeon_chipset.h
radeon_screen.*
radeon_screen.[ch]
radeon_span.h
server

View File

@@ -0,0 +1,2 @@
#!/bin/sh
indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs "$@"

View File

@@ -1,6 +1,5 @@
# src/mesa/drivers/dri/r300/Makefile
TOP = ../../../../..
include $(TOP)/configs/current
@@ -28,8 +27,7 @@ DRIVER_SOURCES = \
radeon_lock.c \
radeon_span.c \
radeon_state.c \
radeon_mm.c \
radeon_vtxfmt_a.c \
r300_mem.c \
\
r300_context.c \
r300_ioctl.c \
@@ -42,34 +40,12 @@ DRIVER_SOURCES = \
r300_vertprog.c \
r300_fragprog.c \
r300_shader.c \
r300_maos.c \
r300_emit.c \
$(EGL_SOURCES)
# \
# r200_context.c \
# r200_ioctl.c \
# r200_state.c \
# r200_state_init.c \
# r200_cmdbuf.c \
# r200_pixel.c \
# r200_tex.c \
# r200_texmem.c \
# r200_texstate.c \
# r200_swtcl.c \
# r200_maos.c \
# r200_sanity.c \
# r200_vtxfmt.c \
# r200_vtxfmt_c.c \
# r200_vtxfmt_sse.c \
# r200_vtxfmt_x86.c
C_SOURCES = $(COMMON_SOURCES) $(DRIVER_SOURCES)
X86_SOURCES =
#r200_vtxtmp_x86.S
DRIVER_DEFINES = -DCOMPILE_R300 -DGLX_DIRECT_RENDERING -DR200_MERGED=0 \
DRIVER_DEFINES = -DCOMPILE_R300 -DR200_MERGED=0 \
-DRADEON_COMMON=1 -DRADEON_COMMON_FOR_R300
SYMLINKS = \
@@ -83,11 +59,11 @@ SYMLINKS = \
COMMON_SYMLINKS = \
radeon_chipset.h \
radeon_screen.c \
radeon_screen.h
radeon_screen.h \
radeon_span.h
##### TARGETS #####
include ../Makefile.template
server:
@@ -100,4 +76,3 @@ $(COMMON_SYMLINKS):
@[ -e $@ ] || ln -sf ../radeon/$@ ./
symlinks: $(SYMLINKS) $(COMMON_SYMLINKS)

View File

@@ -1,103 +0,0 @@
#ifndef __PIXEL_SHADER_H__
#define __PIXEL_SHADER_H__
#include "r300_reg.h"
/* INSTR 0 */
#define PFS_OP_MAD 0
#define PFS_OP_DP3 1
#define PFS_OP_DP4 2
#define PFS_OP_MIN 4
#define PFS_OP_MAX 5
#define PFS_OP_CMP 8
#define PFS_OP_FRC 9
#define PFS_OP_OUTC_REPL_ALPHA 10
/* "or" these with arg0 value to negate or take absolute value of an argument */
#define PFS_ARG_NEG (1<<5)
#define PFS_ARG_ABS (1<<6)
#define MAKE_PFS_INSTR0(op, arg0, arg1, arg2, flags) \
( ((op)<<23) \
| ((arg0)<<R300_FPI0_ARG0C_SHIFT) \
| ((arg1)<<R300_FPI0_ARG1C_SHIFT) \
| ((arg2)<<R300_FPI0_ARG2C_SHIFT) \
| (flags) \
)
#define PFS_FLAG_X 1
#define PFS_FLAG_Y 2
#define PFS_FLAG_XY 3
#define PFS_FLAG_Z 4
#define PFS_FLAG_XZ 5
#define PFS_FLAG_YZ 6
#define PFS_FLAG_ALL 7
#define PFS_FLAG_NONE 0
#define EASY_PFS_INSTR0(op, arg0, arg1, arg2) \
MAKE_PFS_INSTR0(PFS_OP_##op, \
R300_FPI0_ARGC_##arg0, \
R300_FPI0_ARGC_##arg1, \
R300_FPI0_ARGC_##arg2, \
0)
/* INSTR 1 */
#define PFS_FLAG_CONST (1<<5)
#define MAKE_PFS_INSTR1(dstc, src0, src1, src2, reg, output) \
((src0) | ((src1) << R300_FPI1_SRC1C_SHIFT) \
| ((src2)<<R300_FPI1_SRC2C_SHIFT) \
| ((dstc) << R300_FPI1_DSTC_SHIFT) \
| ((reg) << 23) | ((output)<<26))
#define EASY_PFS_INSTR1(dstc, src0, src1, src2, reg, output) \
MAKE_PFS_INSTR1(dstc, src0, src1, src2, PFS_FLAG_##reg, PFS_FLAG_##output)
/* INSTR 2 */
/* you can "or" PFS_ARG_NEG with these values to negate them */
#define MAKE_PFS_INSTR2(op, arg0, arg1, arg2, flags) \
(((op) << 23) | \
((arg0)<<R300_FPI2_ARG0A_SHIFT) | \
((arg1)<<R300_FPI2_ARG1A_SHIFT) | \
((arg2)<<R300_FPI2_ARG2A_SHIFT) | \
(flags))
#define EASY_PFS_INSTR2(op, arg0, arg1, arg2) \
MAKE_PFS_INSTR2(R300_FPI2_OUTA_##op, \
R300_FPI2_ARGA_##arg0, \
R300_FPI2_ARGA_##arg1, \
R300_FPI2_ARGA_##arg2, \
0)
/* INSTR 3 */
#define PFS_FLAG_NONE 0
#define PFS_FLAG_REG 1
#define PFS_FLAG_OUTPUT 2
#define PFS_FLAG_BOTH 3
#define MAKE_PFS_INSTR3(dstc, src0, src1, src2, flags) \
((src0) | ((src1) << R300_FPI1_SRC1C_SHIFT) \
| ((src2)<<R300_FPI1_SRC2C_SHIFT) \
| ((dstc) << R300_FPI1_DSTC_SHIFT) \
| ((flags) << 23))
#define EASY_PFS_INSTR3(dstc, src0, src1, src2, flag) \
MAKE_PFS_INSTR3(dstc, src0, src1, src2, PFS_FLAG_##flag)
/* What are 0's ORed with flags ? They are register numbers that
just happen to be 0 */
#define PFS_NOP { \
EASY_PFS_INSTR0(MAD, SRC0C_XYZ, ONE, ZERO), \
EASY_PFS_INSTR1(0, 0, 0 | PFS_FLAG_CONST, 0 | PFS_FLAG_CONST, NONE, ALL), \
EASY_PFS_INSTR2(MAD, SRC0A, ONE, ZERO), \
EASY_PFS_INSTR3(0, 0, 0 | PFS_FLAG_CONST, 0 | PFS_FLAG_CONST, OUTPUT) \
}
#endif

View File

@@ -27,9 +27,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
/*
* Authors:
* Nicolai Haehnle <prefect_@gmx.net>
/**
* \file
*
* \author Nicolai Haehnle <prefect_@gmx.net>
*/
#include "glheader.h"
@@ -52,15 +53,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r300_emit.h"
#include "r300_state.h"
// Set this to 1 for extremely verbose debugging of command buffers
#define DEBUG_CMDBUF 0
/**
* Send the current command buffer via ioctl to the hardware.
*/
int r300FlushCmdBufLocked(r300ContextPtr r300, const char* caller)
int r300FlushCmdBufLocked(r300ContextPtr r300, const char *caller)
{
int ret;
int i;
@@ -83,22 +82,24 @@ int r300FlushCmdBufLocked(r300ContextPtr r300, const char* caller)
r300->cmdbuf.cmd_buf[i]);
}
cmd.buf = (char*)(r300->cmdbuf.cmd_buf + start);
cmd.buf = (char *)(r300->cmdbuf.cmd_buf + start);
cmd.bufsz = (r300->cmdbuf.count_used - start) * 4;
if (r300->radeon.state.scissor.enabled) {
cmd.nbox = r300->radeon.state.scissor.numClipRects;
cmd.boxes = (drm_clip_rect_t *)r300->radeon.state.scissor.pClipRects;
cmd.boxes =
(drm_clip_rect_t *) r300->radeon.state.scissor.pClipRects;
} else {
cmd.nbox = r300->radeon.numClipRects;
cmd.boxes = (drm_clip_rect_t *)r300->radeon.pClipRects;
cmd.boxes = (drm_clip_rect_t *) r300->radeon.pClipRects;
}
ret = drmCommandWrite(r300->radeon.dri.fd,
DRM_RADEON_CMDBUF, &cmd, sizeof(cmd));
DRM_RADEON_CMDBUF, &cmd, sizeof(cmd));
if (RADEON_DEBUG & DEBUG_SYNC) {
fprintf(stderr, "Syncing in %s (from %s)\n\n", __FUNCTION__, caller);
fprintf(stderr, "Syncing in %s (from %s)\n\n",
__FUNCTION__, caller);
radeonWaitForIdleLocked(&r300->radeon);
}
@@ -109,37 +110,36 @@ int r300FlushCmdBufLocked(r300ContextPtr r300, const char* caller)
return ret;
}
int r300FlushCmdBuf(r300ContextPtr r300, const char* caller)
int r300FlushCmdBuf(r300ContextPtr r300, const char *caller)
{
int ret;
LOCK_HARDWARE(&r300->radeon);
ret=r300FlushCmdBufLocked(r300, caller);
ret = r300FlushCmdBufLocked(r300, caller);
UNLOCK_HARDWARE(&r300->radeon);
if (ret) {
fprintf(stderr, "drmRadeonCmdBuffer: %d (exiting)\n", ret);
exit(ret);
fprintf(stderr, "drmRadeonCmdBuffer: %d\n", ret);
_mesa_exit(ret);
}
return ret;
}
void r300_print_state_atom(r300ContextPtr r300, struct r300_state_atom *state)
static void r300PrintStateAtom(r300ContextPtr r300, struct r300_state_atom *state)
{
int i;
int dwords = (*state->check)(r300, state);
int dwords = (*state->check) (r300, state);
fprintf(stderr, " emit %s/%d/%d\n", state->name, dwords, state->cmd_size);
fprintf(stderr, " emit %s/%d/%d\n", state->name, dwords,
state->cmd_size);
if (RADEON_DEBUG & DEBUG_VERBOSE)
for (i = 0; i < dwords; i++)
fprintf(stderr, " %s[%d]: %08X\n", state->name, i,
state->cmd[i]);
fprintf(stderr, " %s[%d]: %08X\n",
state->name, i, state->cmd[i]);
}
/**
@@ -148,22 +148,23 @@ void r300_print_state_atom(r300ContextPtr r300, struct r300_state_atom *state)
* The caller must have ensured that there is enough space in the command
* buffer.
*/
static __inline__ void r300DoEmitState(r300ContextPtr r300, GLboolean dirty)
static __inline__ void r300EmitAtoms(r300ContextPtr r300, GLboolean dirty)
{
struct r300_state_atom* atom;
uint32_t* dest;
struct r300_state_atom *atom;
uint32_t *dest;
dest = r300->cmdbuf.cmd_buf + r300->cmdbuf.count_used;
if (DEBUG_CMDBUF && RADEON_DEBUG & DEBUG_STATE) {
foreach(atom, &r300->hw.atomlist) {
if ((atom->dirty || r300->hw.all_dirty) == dirty) {
int dwords = (*atom->check)(r300, atom);
int dwords = (*atom->check) (r300, atom);
if (dwords)
r300_print_state_atom(r300, atom);
r300PrintStateAtom(r300, atom);
else
fprintf(stderr, " skip state %s\n",
fprintf(stderr,
" skip state %s\n",
atom->name);
}
}
@@ -171,32 +172,31 @@ static __inline__ void r300DoEmitState(r300ContextPtr r300, GLboolean dirty)
/* Emit WAIT */
*dest = cmdwait(R300_WAIT_3D | R300_WAIT_3D_CLEAN);
dest ++;
r300->cmdbuf.count_used ++;
dest++;
r300->cmdbuf.count_used++;
/* Emit cache flush */
*dest = cmdpacket0(R300_TX_CNTL, 1);
dest ++;
r300->cmdbuf.count_used ++;
dest++;
r300->cmdbuf.count_used++;
*dest = R300_TX_FLUSH;
dest ++;
r300->cmdbuf.count_used ++;
dest++;
r300->cmdbuf.count_used++;
/* Emit END3D */
*dest = cmdpacify();
dest ++;
r300->cmdbuf.count_used ++;
dest++;
r300->cmdbuf.count_used++;
/* Emit actual atoms */
foreach(atom, &r300->hw.atomlist) {
if ((atom->dirty || r300->hw.all_dirty) == dirty) {
int dwords = (*atom->check)(r300, atom);
int dwords = (*atom->check) (r300, atom);
if (dwords) {
memcpy(dest, atom->cmd, dwords*4);
memcpy(dest, atom->cmd, dwords * 4);
dest += dwords;
r300->cmdbuf.count_used += dwords;
atom->dirty = GL_FALSE;
@@ -216,7 +216,8 @@ void r300EmitState(r300ContextPtr r300)
if (RADEON_DEBUG & (DEBUG_STATE | DEBUG_PRIMS))
fprintf(stderr, "%s\n", __FUNCTION__);
if (r300->cmdbuf.count_used && !r300->hw.is_dirty && !r300->hw.all_dirty)
if (r300->cmdbuf.count_used && !r300->hw.is_dirty
&& !r300->hw.all_dirty)
return;
/* To avoid going across the entire set of states multiple times, just check
@@ -229,14 +230,14 @@ void r300EmitState(r300ContextPtr r300)
if (RADEON_DEBUG & DEBUG_STATE)
fprintf(stderr, "Begin reemit state\n");
r300DoEmitState(r300, GL_FALSE);
r300EmitAtoms(r300, GL_FALSE);
r300->cmdbuf.count_reemit = r300->cmdbuf.count_used;
}
if (RADEON_DEBUG & DEBUG_STATE)
fprintf(stderr, "Begin dirty state\n");
r300DoEmitState(r300, GL_TRUE);
r300EmitAtoms(r300, GL_TRUE);
assert(r300->cmdbuf.count_used < r300->cmdbuf.size);
@@ -255,25 +256,22 @@ static int check_##NM( r300ContextPtr r300, \
#define packet0_count(ptr) (((drm_r300_cmd_header_t*)(ptr))->packet0.count)
#define vpu_count(ptr) (((drm_r300_cmd_header_t*)(ptr))->vpu.count)
CHECK( always, atom->cmd_size )
CHECK( variable, packet0_count(atom->cmd) ? (1 + packet0_count(atom->cmd)) : 0 )
CHECK( vpu, vpu_count(atom->cmd) ? (1 + vpu_count(atom->cmd)*4) : 0 )
CHECK(always, atom->cmd_size)
CHECK(variable, packet0_count(atom->cmd) ? (1 + packet0_count(atom->cmd)) : 0)
CHECK(vpu, vpu_count(atom->cmd) ? (1 + vpu_count(atom->cmd) * 4) : 0)
#undef packet0_count
#undef vpu_count
#define ALLOC_STATE( ATOM, CHK, SZ, NM, IDX ) \
#define ALLOC_STATE( ATOM, CHK, SZ, IDX ) \
do { \
r300->hw.ATOM.cmd_size = (SZ); \
r300->hw.ATOM.cmd = (uint32_t*)CALLOC((SZ) * sizeof(uint32_t)); \
r300->hw.ATOM.name = (NM); \
r300->hw.ATOM.name = #ATOM; \
r300->hw.ATOM.idx = (IDX); \
r300->hw.ATOM.check = check_##CHK; \
r300->hw.ATOM.dirty = GL_FALSE; \
r300->hw.max_state_size += (SZ); \
insert_at_tail(&r300->hw.atomlist, &r300->hw.ATOM); \
} while (0)
/**
* Allocate memory for the command buffer and initialize the state atom
* list. Note that the initial hardware state is set by r300InitState().
@@ -284,304 +282,239 @@ void r300InitCmdBuf(r300ContextPtr r300)
int has_tcl = 1;
if (!(r300->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL))
has_tcl = 0;
has_tcl = 0;
r300->hw.max_state_size = 2+2; /* reserve extra space for WAIT_IDLE and tex cache flush */
r300->hw.max_state_size = 2 + 2; /* reserve extra space for WAIT_IDLE and tex cache flush */
mtu = r300->radeon.glCtx->Const.MaxTextureUnits;
if (RADEON_DEBUG & DEBUG_TEXTURE) {
fprintf(stderr, "Using %d maximum texture units..\n", mtu);
}
/* Initialize state atoms */
ALLOC_STATE( vpt, always, R300_VPT_CMDSIZE, "vpt", 0 );
r300->hw.vpt.cmd[R300_VPT_CMD_0] = cmdpacket0(R300_SE_VPORT_XSCALE, 6);
ALLOC_STATE( vap_cntl, always, 2, "vap_cntl", 0 );
r300->hw.vap_cntl.cmd[0] = cmdpacket0(R300_VAP_CNTL, 1);
ALLOC_STATE( vte, always, 3, "vte", 0 );
r300->hw.vte.cmd[0] = cmdpacket0(R300_SE_VTE_CNTL, 2);
ALLOC_STATE( unk2134, always, 3, "unk2134", 0 );
r300->hw.unk2134.cmd[0] = cmdpacket0(0x2134, 2);
ALLOC_STATE( vap_cntl_status, always, 2, "vap_cntl_status", 0 );
r300->hw.vap_cntl_status.cmd[0] = cmdpacket0(R300_VAP_CNTL_STATUS, 1);
ALLOC_STATE( vir[0], variable, R300_VIR_CMDSIZE, "vir/0", 0 );
r300->hw.vir[0].cmd[R300_VIR_CMD_0] = cmdpacket0(R300_VAP_INPUT_ROUTE_0_0, 1);
ALLOC_STATE( vir[1], variable, R300_VIR_CMDSIZE, "vir/1", 1 );
r300->hw.vir[1].cmd[R300_VIR_CMD_0] = cmdpacket0(R300_VAP_INPUT_ROUTE_1_0, 1);
ALLOC_STATE( vic, always, R300_VIC_CMDSIZE, "vic", 0 );
r300->hw.vic.cmd[R300_VIC_CMD_0] = cmdpacket0(R300_VAP_INPUT_CNTL_0, 2);
ALLOC_STATE( unk21DC, always, 2, "unk21DC", 0 );
r300->hw.unk21DC.cmd[0] = cmdpacket0(0x21DC, 1);
ALLOC_STATE( unk221C, always, 2, "unk221C", 0 );
r300->hw.unk221C.cmd[0] = cmdpacket0(R300_VAP_UNKNOWN_221C, 1);
ALLOC_STATE( unk2220, always, 5, "unk2220", 0 );
r300->hw.unk2220.cmd[0] = cmdpacket0(0x2220, 4);
ALLOC_STATE( unk2288, always, 2, "unk2288", 0 );
r300->hw.unk2288.cmd[0] = cmdpacket0(R300_VAP_UNKNOWN_2288, 1);
ALLOC_STATE( vof, always, R300_VOF_CMDSIZE, "vof", 0 );
r300->hw.vof.cmd[R300_VOF_CMD_0] = cmdpacket0(R300_VAP_OUTPUT_VTX_FMT_0, 2);
if (has_tcl) {
ALLOC_STATE( pvs, always, R300_PVS_CMDSIZE, "pvs", 0 );
r300->hw.pvs.cmd[R300_PVS_CMD_0] = cmdpacket0(R300_VAP_PVS_CNTL_1, 3);
}
ALLOC_STATE( gb_enable, always, 2, "gb_enable", 0 );
r300->hw.gb_enable.cmd[0] = cmdpacket0(R300_GB_ENABLE, 1);
ALLOC_STATE( gb_misc, always, R300_GB_MISC_CMDSIZE, "gb_misc", 0 );
r300->hw.gb_misc.cmd[0] = cmdpacket0(R300_GB_MSPOS0, 5);
ALLOC_STATE( txe, always, R300_TXE_CMDSIZE, "txe", 0 );
r300->hw.txe.cmd[R300_TXE_CMD_0] = cmdpacket0(R300_TX_ENABLE, 1);
ALLOC_STATE( unk4200, always, 5, "unk4200", 0 );
r300->hw.unk4200.cmd[0] = cmdpacket0(0x4200, 4);
ALLOC_STATE( unk4214, always, 2, "unk4214", 0 );
r300->hw.unk4214.cmd[0] = cmdpacket0(0x4214, 1);
ALLOC_STATE( ps, always, R300_PS_CMDSIZE, "ps", 0 );
r300->hw.ps.cmd[0] = cmdpacket0(R300_RE_POINTSIZE, 1);
ALLOC_STATE( unk4230, always, 4, "unk4230", 0 );
r300->hw.unk4230.cmd[0] = cmdpacket0(0x4230, 3);
ALLOC_STATE( lcntl, always, 2, "lcntl", 0 );
r300->hw.lcntl.cmd[0] = cmdpacket0(R300_RE_LINE_CNT, 1);
ALLOC_STATE( unk4260, always, 4, "unk4260", 0 );
r300->hw.unk4260.cmd[0] = cmdpacket0(0x4260, 3);
ALLOC_STATE( shade, always, 5, "shade", 0 );
r300->hw.shade.cmd[0] = cmdpacket0(R300_RE_SHADE, 4);
ALLOC_STATE( polygon_mode, always, 4, "polygon_mode", 0 );
r300->hw.polygon_mode.cmd[0] = cmdpacket0(R300_RE_POLYGON_MODE, 3);
ALLOC_STATE( fogp, always, 3, "fogp", 0 );
r300->hw.fogp.cmd[0] = cmdpacket0(R300_RE_FOG_SCALE, 2);
ALLOC_STATE( zbias_cntl, always, 2, "zbias_cntl", 0 );
r300->hw.zbias_cntl.cmd[0] = cmdpacket0(R300_RE_ZBIAS_CNTL, 1);
ALLOC_STATE( zbs, always, R300_ZBS_CMDSIZE, "zbs", 0 );
r300->hw.zbs.cmd[R300_ZBS_CMD_0] = cmdpacket0(R300_RE_ZBIAS_T_FACTOR, 4);
ALLOC_STATE( occlusion_cntl, always, 2, "occlusion_cntl", 0 );
r300->hw.occlusion_cntl.cmd[0] = cmdpacket0(R300_RE_OCCLUSION_CNTL, 1);
ALLOC_STATE( cul, always, R300_CUL_CMDSIZE, "cul", 0 );
r300->hw.cul.cmd[R300_CUL_CMD_0] = cmdpacket0(R300_RE_CULL_CNTL, 1);
ALLOC_STATE( unk42C0, always, 3, "unk42C0", 0 );
r300->hw.unk42C0.cmd[0] = cmdpacket0(0x42C0, 2);
ALLOC_STATE( rc, always, R300_RC_CMDSIZE, "rc", 0 );
r300->hw.rc.cmd[R300_RC_CMD_0] = cmdpacket0(R300_RS_CNTL_0, 2);
ALLOC_STATE( ri, always, R300_RI_CMDSIZE, "ri", 0 );
r300->hw.ri.cmd[R300_RI_CMD_0] = cmdpacket0(R300_RS_INTERP_0, 8);
ALLOC_STATE( rr, variable, R300_RR_CMDSIZE, "rr", 0 );
r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(R300_RS_ROUTE_0, 1);
ALLOC_STATE( unk43A4, always, 3, "unk43A4", 0 );
r300->hw.unk43A4.cmd[0] = cmdpacket0(0x43A4, 2);
ALLOC_STATE( unk43E8, always, 2, "unk43E8", 0 );
r300->hw.unk43E8.cmd[0] = cmdpacket0(0x43E8, 1);
ALLOC_STATE( fp, always, R300_FP_CMDSIZE, "fp", 0 );
r300->hw.fp.cmd[R300_FP_CMD_0] = cmdpacket0(R300_PFS_CNTL_0, 3);
r300->hw.fp.cmd[R300_FP_CMD_1] = cmdpacket0(R300_PFS_NODE_0, 4);
ALLOC_STATE( fpt, variable, R300_FPT_CMDSIZE, "fpt", 0 );
r300->hw.fpt.cmd[R300_FPT_CMD_0] = cmdpacket0(R300_PFS_TEXI_0, 0);
ALLOC_STATE( unk46A4, always, 6, "unk46A4", 0 );
r300->hw.unk46A4.cmd[0] = cmdpacket0(0x46A4, 5);
ALLOC_STATE( fpi[0], variable, R300_FPI_CMDSIZE, "fpi/0", 0 );
r300->hw.fpi[0].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR0_0, 1);
ALLOC_STATE( fpi[1], variable, R300_FPI_CMDSIZE, "fpi/1", 1 );
r300->hw.fpi[1].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR1_0, 1);
ALLOC_STATE( fpi[2], variable, R300_FPI_CMDSIZE, "fpi/2", 2 );
r300->hw.fpi[2].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR2_0, 1);
ALLOC_STATE( fpi[3], variable, R300_FPI_CMDSIZE, "fpi/3", 3 );
r300->hw.fpi[3].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR3_0, 1);
ALLOC_STATE( fogs, always, R300_FOGS_CMDSIZE, "fogs", 0 );
r300->hw.fogs.cmd[R300_FOGS_CMD_0] = cmdpacket0(R300_RE_FOG_STATE, 1);
ALLOC_STATE( fogc, always, R300_FOGC_CMDSIZE, "fogc", 0 );
r300->hw.fogc.cmd[R300_FOGC_CMD_0] = cmdpacket0(R300_FOG_COLOR_R, 3);
ALLOC_STATE( at, always, R300_AT_CMDSIZE, "at", 0 );
r300->hw.at.cmd[R300_AT_CMD_0] = cmdpacket0(R300_PP_ALPHA_TEST, 2);
ALLOC_STATE( unk4BD8, always, 2, "unk4BD8", 0 );
r300->hw.unk4BD8.cmd[0] = cmdpacket0(0x4BD8, 1);
ALLOC_STATE( fpp, variable, R300_FPP_CMDSIZE, "fpp", 0 );
r300->hw.fpp.cmd[R300_FPP_CMD_0] = cmdpacket0(R300_PFS_PARAM_0_X, 0);
ALLOC_STATE( unk4E00, always, 2, "unk4E00", 0 );
r300->hw.unk4E00.cmd[0] = cmdpacket0(0x4E00, 1);
ALLOC_STATE( bld, always, R300_BLD_CMDSIZE, "bld", 0 );
r300->hw.bld.cmd[R300_BLD_CMD_0] = cmdpacket0(R300_RB3D_CBLEND, 2);
ALLOC_STATE( cmk, always, R300_CMK_CMDSIZE, "cmk", 0 );
r300->hw.cmk.cmd[R300_CMK_CMD_0] = cmdpacket0(R300_RB3D_COLORMASK, 1);
ALLOC_STATE( blend_color, always, 4, "blend_color", 0 );
r300->hw.blend_color.cmd[0] = cmdpacket0(R300_RB3D_BLEND_COLOR, 3);
ALLOC_STATE( cb, always, R300_CB_CMDSIZE, "cb", 0 );
r300->hw.cb.cmd[R300_CB_CMD_0] = cmdpacket0(R300_RB3D_COLOROFFSET0, 1);
r300->hw.cb.cmd[R300_CB_CMD_1] = cmdpacket0(R300_RB3D_COLORPITCH0, 1);
ALLOC_STATE( unk4E50, always, 10, "unk4E50", 0 );
r300->hw.unk4E50.cmd[0] = cmdpacket0(0x4E50, 9);
ALLOC_STATE( unk4E88, always, 2, "unk4E88", 0 );
r300->hw.unk4E88.cmd[0] = cmdpacket0(0x4E88, 1);
ALLOC_STATE( unk4EA0, always, 3, "unk4EA0 R350 only", 0 );
r300->hw.unk4EA0.cmd[0] = cmdpacket0(0x4EA0, 2);
ALLOC_STATE( zs, always, R300_ZS_CMDSIZE, "zstencil", 0 );
r300->hw.zs.cmd[R300_ZS_CMD_0] = cmdpacket0(R300_RB3D_ZSTENCIL_CNTL_0, 3);
ALLOC_STATE( zstencil_format, always, 5, "zstencil_format", 0 );
r300->hw.zstencil_format.cmd[0] = cmdpacket0(R300_RB3D_ZSTENCIL_FORMAT, 4);
ALLOC_STATE( zb, always, R300_ZB_CMDSIZE, "zb", 0 );
r300->hw.zb.cmd[R300_ZB_CMD_0] = cmdpacket0(R300_RB3D_DEPTHOFFSET, 2);
ALLOC_STATE( unk4F28, always, 2, "unk4F28", 0 );
r300->hw.unk4F28.cmd[0] = cmdpacket0(0x4F28, 1);
ALLOC_STATE( unk4F30, always, 3, "unk4F30", 0 );
r300->hw.unk4F30.cmd[0] = cmdpacket0(0x4F30, 2);
ALLOC_STATE( unk4F44, always, 2, "unk4F44", 0 );
r300->hw.unk4F44.cmd[0] = cmdpacket0(0x4F44, 1);
ALLOC_STATE( unk4F54, always, 2, "unk4F54", 0 );
r300->hw.unk4F54.cmd[0] = cmdpacket0(0x4F54, 1);
/* VPU only on TCL */
if (has_tcl) {
ALLOC_STATE( vpi, vpu, R300_VPI_CMDSIZE, "vpi", 0 );
r300->hw.vpi.cmd[R300_VPI_CMD_0] = cmdvpu(R300_PVS_UPLOAD_PROGRAM, 0);
ALLOC_STATE( vpp, vpu, R300_VPP_CMDSIZE, "vpp", 0 );
r300->hw.vpp.cmd[R300_VPP_CMD_0] = cmdvpu(R300_PVS_UPLOAD_PARAMETERS, 0);
ALLOC_STATE( vps, vpu, R300_VPS_CMDSIZE, "vps", 0 );
r300->hw.vps.cmd[R300_VPS_CMD_0] = cmdvpu(R300_PVS_UPLOAD_POINTSIZE, 1);
}
/* Textures */
ALLOC_STATE( tex.filter, variable, mtu+1, "tex_filter", 0 );
r300->hw.tex.filter.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_FILTER_0, 0);
ALLOC_STATE( tex.filter_1, variable, mtu+1, "tex_filter_1", 0 );
r300->hw.tex.filter_1.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_FILTER1_0, 0);
ALLOC_STATE( tex.size, variable, mtu+1, "tex_size", 0 );
r300->hw.tex.size.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_SIZE_0, 0);
ALLOC_STATE( tex.format, variable, mtu+1, "tex_format", 0 );
r300->hw.tex.format.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_FORMAT_0, 0);
ALLOC_STATE( tex.pitch, variable, mtu+1, "tex_pitch", 0 );
r300->hw.tex.pitch.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_PITCH_0, 0);
ALLOC_STATE( tex.offset, variable, mtu+1, "tex_offset", 0 );
r300->hw.tex.offset.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_OFFSET_0, 0);
ALLOC_STATE( tex.chroma_key, variable, mtu+1, "tex_chroma_key", 0 );
r300->hw.tex.chroma_key.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_CHROMA_KEY_0, 0);
ALLOC_STATE( tex.border_color, variable, mtu+1, "tex_border_color", 0 );
r300->hw.tex.border_color.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_BORDER_COLOR_0, 0);
/* Setup the atom linked list */
make_empty_list(&r300->hw.atomlist);
r300->hw.atomlist.name = "atom-list";
insert_at_tail(&r300->hw.atomlist, &r300->hw.vpt);
insert_at_tail(&r300->hw.atomlist, &r300->hw.vap_cntl);
insert_at_tail(&r300->hw.atomlist, &r300->hw.vte);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk2134);
insert_at_tail(&r300->hw.atomlist, &r300->hw.vap_cntl_status);
insert_at_tail(&r300->hw.atomlist, &r300->hw.vir[0]);
insert_at_tail(&r300->hw.atomlist, &r300->hw.vir[1]);
insert_at_tail(&r300->hw.atomlist, &r300->hw.vic);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk21DC);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk221C);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk2220);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk2288);
insert_at_tail(&r300->hw.atomlist, &r300->hw.vof);
if (has_tcl)
insert_at_tail(&r300->hw.atomlist, &r300->hw.pvs);
insert_at_tail(&r300->hw.atomlist, &r300->hw.gb_enable);
insert_at_tail(&r300->hw.atomlist, &r300->hw.gb_misc);
insert_at_tail(&r300->hw.atomlist, &r300->hw.txe);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4200);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4214);
insert_at_tail(&r300->hw.atomlist, &r300->hw.ps);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4230);
insert_at_tail(&r300->hw.atomlist, &r300->hw.lcntl);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4260);
insert_at_tail(&r300->hw.atomlist, &r300->hw.shade);
insert_at_tail(&r300->hw.atomlist, &r300->hw.polygon_mode);
insert_at_tail(&r300->hw.atomlist, &r300->hw.fogp);
insert_at_tail(&r300->hw.atomlist, &r300->hw.zbias_cntl);
insert_at_tail(&r300->hw.atomlist, &r300->hw.zbs);
insert_at_tail(&r300->hw.atomlist, &r300->hw.occlusion_cntl);
insert_at_tail(&r300->hw.atomlist, &r300->hw.cul);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk42C0);
insert_at_tail(&r300->hw.atomlist, &r300->hw.rc);
insert_at_tail(&r300->hw.atomlist, &r300->hw.ri);
insert_at_tail(&r300->hw.atomlist, &r300->hw.rr);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk43A4);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk43E8);
insert_at_tail(&r300->hw.atomlist, &r300->hw.fp);
insert_at_tail(&r300->hw.atomlist, &r300->hw.fpt);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk46A4);
insert_at_tail(&r300->hw.atomlist, &r300->hw.fpi[0]);
insert_at_tail(&r300->hw.atomlist, &r300->hw.fpi[1]);
insert_at_tail(&r300->hw.atomlist, &r300->hw.fpi[2]);
insert_at_tail(&r300->hw.atomlist, &r300->hw.fpi[3]);
insert_at_tail(&r300->hw.atomlist, &r300->hw.fogs);
insert_at_tail(&r300->hw.atomlist, &r300->hw.fogc);
insert_at_tail(&r300->hw.atomlist, &r300->hw.at);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4BD8);
insert_at_tail(&r300->hw.atomlist, &r300->hw.fpp);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4E00);
insert_at_tail(&r300->hw.atomlist, &r300->hw.bld);
insert_at_tail(&r300->hw.atomlist, &r300->hw.cmk);
insert_at_tail(&r300->hw.atomlist, &r300->hw.blend_color);
insert_at_tail(&r300->hw.atomlist, &r300->hw.cb);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4E50);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4E88);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4EA0);
insert_at_tail(&r300->hw.atomlist, &r300->hw.zs);
insert_at_tail(&r300->hw.atomlist, &r300->hw.zstencil_format);
insert_at_tail(&r300->hw.atomlist, &r300->hw.zb);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4F28);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4F30);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4F44);
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4F54);
/* Initialize state atoms */
ALLOC_STATE(vpt, always, R300_VPT_CMDSIZE, 0);
r300->hw.vpt.cmd[R300_VPT_CMD_0] = cmdpacket0(R300_SE_VPORT_XSCALE, 6);
ALLOC_STATE(vap_cntl, always, 2, 0);
r300->hw.vap_cntl.cmd[0] = cmdpacket0(R300_VAP_CNTL, 1);
ALLOC_STATE(vte, always, 3, 0);
r300->hw.vte.cmd[0] = cmdpacket0(R300_SE_VTE_CNTL, 2);
ALLOC_STATE(unk2134, always, 3, 0);
r300->hw.unk2134.cmd[0] = cmdpacket0(0x2134, 2);
ALLOC_STATE(vap_cntl_status, always, 2, 0);
r300->hw.vap_cntl_status.cmd[0] = cmdpacket0(R300_VAP_CNTL_STATUS, 1);
ALLOC_STATE(vir[0], variable, R300_VIR_CMDSIZE, 0);
r300->hw.vir[0].cmd[R300_VIR_CMD_0] =
cmdpacket0(R300_VAP_INPUT_ROUTE_0_0, 1);
ALLOC_STATE(vir[1], variable, R300_VIR_CMDSIZE, 1);
r300->hw.vir[1].cmd[R300_VIR_CMD_0] =
cmdpacket0(R300_VAP_INPUT_ROUTE_1_0, 1);
ALLOC_STATE(vic, always, R300_VIC_CMDSIZE, 0);
r300->hw.vic.cmd[R300_VIC_CMD_0] = cmdpacket0(R300_VAP_INPUT_CNTL_0, 2);
ALLOC_STATE(unk21DC, always, 2, 0);
r300->hw.unk21DC.cmd[0] = cmdpacket0(0x21DC, 1);
ALLOC_STATE(unk221C, always, 2, 0);
r300->hw.unk221C.cmd[0] = cmdpacket0(R300_VAP_UNKNOWN_221C, 1);
ALLOC_STATE(unk2220, always, 5, 0);
r300->hw.unk2220.cmd[0] = cmdpacket0(0x2220, 4);
ALLOC_STATE(unk2288, always, 2, 0);
r300->hw.unk2288.cmd[0] = cmdpacket0(R300_VAP_UNKNOWN_2288, 1);
ALLOC_STATE(vof, always, R300_VOF_CMDSIZE, 0);
r300->hw.vof.cmd[R300_VOF_CMD_0] =
cmdpacket0(R300_VAP_OUTPUT_VTX_FMT_0, 2);
if (has_tcl) {
insert_at_tail(&r300->hw.atomlist, &r300->hw.vpi);
insert_at_tail(&r300->hw.atomlist, &r300->hw.vpp);
insert_at_tail(&r300->hw.atomlist, &r300->hw.vps);
ALLOC_STATE(pvs, always, R300_PVS_CMDSIZE, 0);
r300->hw.pvs.cmd[R300_PVS_CMD_0] =
cmdpacket0(R300_VAP_PVS_CNTL_1, 3);
}
insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.filter);
insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.filter_1);
insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.size);
insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.format);
insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.pitch);
insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.offset);
insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.chroma_key);
insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.border_color);
ALLOC_STATE(gb_enable, always, 2, 0);
r300->hw.gb_enable.cmd[0] = cmdpacket0(R300_GB_ENABLE, 1);
ALLOC_STATE(gb_misc, always, R300_GB_MISC_CMDSIZE, 0);
r300->hw.gb_misc.cmd[0] = cmdpacket0(R300_GB_MSPOS0, 5);
ALLOC_STATE(txe, always, R300_TXE_CMDSIZE, 0);
r300->hw.txe.cmd[R300_TXE_CMD_0] = cmdpacket0(R300_TX_ENABLE, 1);
ALLOC_STATE(unk4200, always, 5, 0);
r300->hw.unk4200.cmd[0] = cmdpacket0(0x4200, 4);
ALLOC_STATE(unk4214, always, 2, 0);
r300->hw.unk4214.cmd[0] = cmdpacket0(0x4214, 1);
ALLOC_STATE(ps, always, R300_PS_CMDSIZE, 0);
r300->hw.ps.cmd[0] = cmdpacket0(R300_RE_POINTSIZE, 1);
ALLOC_STATE(unk4230, always, 4, 0);
r300->hw.unk4230.cmd[0] = cmdpacket0(0x4230, 3);
ALLOC_STATE(lcntl, always, 2, 0);
r300->hw.lcntl.cmd[0] = cmdpacket0(R300_RE_LINE_CNT, 1);
ALLOC_STATE(unk4260, always, 4, 0);
r300->hw.unk4260.cmd[0] = cmdpacket0(0x4260, 3);
ALLOC_STATE(shade, always, 5, 0);
r300->hw.shade.cmd[0] = cmdpacket0(R300_RE_SHADE, 4);
ALLOC_STATE(polygon_mode, always, 4, 0);
r300->hw.polygon_mode.cmd[0] = cmdpacket0(R300_RE_POLYGON_MODE, 3);
ALLOC_STATE(fogp, always, 3, 0);
r300->hw.fogp.cmd[0] = cmdpacket0(R300_RE_FOG_SCALE, 2);
ALLOC_STATE(zbias_cntl, always, 2, 0);
r300->hw.zbias_cntl.cmd[0] = cmdpacket0(R300_RE_ZBIAS_CNTL, 1);
ALLOC_STATE(zbs, always, R300_ZBS_CMDSIZE, 0);
r300->hw.zbs.cmd[R300_ZBS_CMD_0] =
cmdpacket0(R300_RE_ZBIAS_T_FACTOR, 4);
ALLOC_STATE(occlusion_cntl, always, 2, 0);
r300->hw.occlusion_cntl.cmd[0] = cmdpacket0(R300_RE_OCCLUSION_CNTL, 1);
ALLOC_STATE(cul, always, R300_CUL_CMDSIZE, 0);
r300->hw.cul.cmd[R300_CUL_CMD_0] = cmdpacket0(R300_RE_CULL_CNTL, 1);
ALLOC_STATE(unk42C0, always, 3, 0);
r300->hw.unk42C0.cmd[0] = cmdpacket0(0x42C0, 2);
ALLOC_STATE(rc, always, R300_RC_CMDSIZE, 0);
r300->hw.rc.cmd[R300_RC_CMD_0] = cmdpacket0(R300_RS_CNTL_0, 2);
ALLOC_STATE(ri, always, R300_RI_CMDSIZE, 0);
r300->hw.ri.cmd[R300_RI_CMD_0] = cmdpacket0(R300_RS_INTERP_0, 8);
ALLOC_STATE(rr, variable, R300_RR_CMDSIZE, 0);
r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(R300_RS_ROUTE_0, 1);
ALLOC_STATE(unk43A4, always, 3, 0);
r300->hw.unk43A4.cmd[0] = cmdpacket0(0x43A4, 2);
ALLOC_STATE(unk43E8, always, 2, 0);
r300->hw.unk43E8.cmd[0] = cmdpacket0(0x43E8, 1);
ALLOC_STATE(fp, always, R300_FP_CMDSIZE, 0);
r300->hw.fp.cmd[R300_FP_CMD_0] = cmdpacket0(R300_PFS_CNTL_0, 3);
r300->hw.fp.cmd[R300_FP_CMD_1] = cmdpacket0(R300_PFS_NODE_0, 4);
ALLOC_STATE(fpt, variable, R300_FPT_CMDSIZE, 0);
r300->hw.fpt.cmd[R300_FPT_CMD_0] = cmdpacket0(R300_PFS_TEXI_0, 0);
ALLOC_STATE(unk46A4, always, 6, 0);
r300->hw.unk46A4.cmd[0] = cmdpacket0(0x46A4, 5);
ALLOC_STATE(fpi[0], variable, R300_FPI_CMDSIZE, 0);
r300->hw.fpi[0].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR0_0, 1);
ALLOC_STATE(fpi[1], variable, R300_FPI_CMDSIZE, 1);
r300->hw.fpi[1].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR1_0, 1);
ALLOC_STATE(fpi[2], variable, R300_FPI_CMDSIZE, 2);
r300->hw.fpi[2].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR2_0, 1);
ALLOC_STATE(fpi[3], variable, R300_FPI_CMDSIZE, 3);
r300->hw.fpi[3].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR3_0, 1);
ALLOC_STATE(fogs, always, R300_FOGS_CMDSIZE, 0);
r300->hw.fogs.cmd[R300_FOGS_CMD_0] = cmdpacket0(R300_RE_FOG_STATE, 1);
ALLOC_STATE(fogc, always, R300_FOGC_CMDSIZE, 0);
r300->hw.fogc.cmd[R300_FOGC_CMD_0] = cmdpacket0(R300_FOG_COLOR_R, 3);
ALLOC_STATE(at, always, R300_AT_CMDSIZE, 0);
r300->hw.at.cmd[R300_AT_CMD_0] = cmdpacket0(R300_PP_ALPHA_TEST, 2);
ALLOC_STATE(unk4BD8, always, 2, 0);
r300->hw.unk4BD8.cmd[0] = cmdpacket0(0x4BD8, 1);
ALLOC_STATE(fpp, variable, R300_FPP_CMDSIZE, 0);
r300->hw.fpp.cmd[R300_FPP_CMD_0] = cmdpacket0(R300_PFS_PARAM_0_X, 0);
ALLOC_STATE(unk4E00, always, 2, 0);
r300->hw.unk4E00.cmd[0] = cmdpacket0(0x4E00, 1);
ALLOC_STATE(bld, always, R300_BLD_CMDSIZE, 0);
r300->hw.bld.cmd[R300_BLD_CMD_0] = cmdpacket0(R300_RB3D_CBLEND, 2);
ALLOC_STATE(cmk, always, R300_CMK_CMDSIZE, 0);
r300->hw.cmk.cmd[R300_CMK_CMD_0] = cmdpacket0(R300_RB3D_COLORMASK, 1);
ALLOC_STATE(blend_color, always, 4, 0);
r300->hw.blend_color.cmd[0] = cmdpacket0(R300_RB3D_BLEND_COLOR, 3);
ALLOC_STATE(cb, always, R300_CB_CMDSIZE, 0);
r300->hw.cb.cmd[R300_CB_CMD_0] = cmdpacket0(R300_RB3D_COLOROFFSET0, 1);
r300->hw.cb.cmd[R300_CB_CMD_1] = cmdpacket0(R300_RB3D_COLORPITCH0, 1);
ALLOC_STATE(unk4E50, always, 10, 0);
r300->hw.unk4E50.cmd[0] = cmdpacket0(0x4E50, 9);
ALLOC_STATE(unk4E88, always, 2, 0);
r300->hw.unk4E88.cmd[0] = cmdpacket0(0x4E88, 1);
ALLOC_STATE(unk4EA0, always, 3, 0);
r300->hw.unk4EA0.cmd[0] = cmdpacket0(0x4EA0, 2);
ALLOC_STATE(zs, always, R300_ZS_CMDSIZE, 0);
r300->hw.zs.cmd[R300_ZS_CMD_0] =
cmdpacket0(R300_RB3D_ZSTENCIL_CNTL_0, 3);
ALLOC_STATE(zstencil_format, always, 5, 0);
r300->hw.zstencil_format.cmd[0] =
cmdpacket0(R300_RB3D_ZSTENCIL_FORMAT, 4);
ALLOC_STATE(zb, always, R300_ZB_CMDSIZE, 0);
r300->hw.zb.cmd[R300_ZB_CMD_0] = cmdpacket0(R300_RB3D_DEPTHOFFSET, 2);
ALLOC_STATE(unk4F28, always, 2, 0);
r300->hw.unk4F28.cmd[0] = cmdpacket0(0x4F28, 1);
ALLOC_STATE(unk4F30, always, 3, 0);
r300->hw.unk4F30.cmd[0] = cmdpacket0(0x4F30, 2);
ALLOC_STATE(unk4F44, always, 2, 0);
r300->hw.unk4F44.cmd[0] = cmdpacket0(0x4F44, 1);
ALLOC_STATE(unk4F54, always, 2, 0);
r300->hw.unk4F54.cmd[0] = cmdpacket0(0x4F54, 1);
/* VPU only on TCL */
if (has_tcl) {
ALLOC_STATE(vpi, vpu, R300_VPI_CMDSIZE, 0);
r300->hw.vpi.cmd[R300_VPI_CMD_0] =
cmdvpu(R300_PVS_UPLOAD_PROGRAM, 0);
ALLOC_STATE(vpp, vpu, R300_VPP_CMDSIZE, 0);
r300->hw.vpp.cmd[R300_VPP_CMD_0] =
cmdvpu(R300_PVS_UPLOAD_PARAMETERS, 0);
ALLOC_STATE(vps, vpu, R300_VPS_CMDSIZE, 0);
r300->hw.vps.cmd[R300_VPS_CMD_0] =
cmdvpu(R300_PVS_UPLOAD_POINTSIZE, 1);
}
/* Textures */
ALLOC_STATE(tex.filter, variable, mtu + 1, 0);
r300->hw.tex.filter.cmd[R300_TEX_CMD_0] =
cmdpacket0(R300_TX_FILTER_0, 0);
ALLOC_STATE(tex.filter_1, variable, mtu + 1, 0);
r300->hw.tex.filter_1.cmd[R300_TEX_CMD_0] =
cmdpacket0(R300_TX_FILTER1_0, 0);
ALLOC_STATE(tex.size, variable, mtu + 1, 0);
r300->hw.tex.size.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_SIZE_0, 0);
ALLOC_STATE(tex.format, variable, mtu + 1, 0);
r300->hw.tex.format.cmd[R300_TEX_CMD_0] =
cmdpacket0(R300_TX_FORMAT_0, 0);
ALLOC_STATE(tex.pitch, variable, mtu + 1, 0);
r300->hw.tex.pitch.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_PITCH_0, 0);
ALLOC_STATE(tex.offset, variable, mtu + 1, 0);
r300->hw.tex.offset.cmd[R300_TEX_CMD_0] =
cmdpacket0(R300_TX_OFFSET_0, 0);
ALLOC_STATE(tex.chroma_key, variable, mtu + 1, 0);
r300->hw.tex.chroma_key.cmd[R300_TEX_CMD_0] =
cmdpacket0(R300_TX_CHROMA_KEY_0, 0);
ALLOC_STATE(tex.border_color, variable, mtu + 1, 0);
r300->hw.tex.border_color.cmd[R300_TEX_CMD_0] =
cmdpacket0(R300_TX_BORDER_COLOR_0, 0);
r300->hw.is_dirty = GL_TRUE;
r300->hw.all_dirty = GL_TRUE;
/* Initialize command buffer */
size = 256 * driQueryOptioni(&r300->radeon.optionCache, "command_buffer_size");
if (size < 2*r300->hw.max_state_size) {
size = 2*r300->hw.max_state_size+65535;
size =
256 * driQueryOptioni(&r300->radeon.optionCache,
"command_buffer_size");
if (size < 2 * r300->hw.max_state_size) {
size = 2 * r300->hw.max_state_size + 65535;
}
if (size > 64*256)
size = 64*256;
if (size > 64 * 256)
size = 64 * 256;
if (RADEON_DEBUG & (DEBUG_IOCTL|DEBUG_DMA)) {
if (RADEON_DEBUG & (DEBUG_IOCTL | DEBUG_DMA)) {
fprintf(stderr, "sizeof(drm_r300_cmd_header_t)=%zd\n",
sizeof(drm_r300_cmd_header_t));
fprintf(stderr, "sizeof(drm_radeon_cmd_buffer_t)=%zd\n",
sizeof(drm_radeon_cmd_buffer_t));
fprintf(stderr,
"Allocating %d bytes command buffer (max state is %d bytes)\n",
size*4, r300->hw.max_state_size*4);
size * 4, r300->hw.max_state_size * 4);
}
r300->cmdbuf.size = size;
r300->cmdbuf.cmd_buf = (uint32_t*)CALLOC(size*4);
r300->cmdbuf.cmd_buf = (uint32_t *) CALLOC(size * 4);
r300->cmdbuf.count_used = 0;
r300->cmdbuf.count_reemit = 0;
}
/**
* Destroy the command buffer and state atoms.
*/
void r300DestroyCmdBuf(r300ContextPtr r300)
{
struct r300_state_atom* atom;
struct r300_state_atom *atom;
FREE(r300->cmdbuf.cmd_buf);
@@ -614,8 +547,7 @@ void r300EmitBlit(r300ContextPtr rmesa,
assert(w < (1 << 16));
assert(h < (1 << 16));
cmd = (drm_r300_cmd_header_t *) r300AllocCmdBuf(rmesa, 8,
__FUNCTION__);
cmd = (drm_r300_cmd_header_t *) r300AllocCmdBuf(rmesa, 8, __FUNCTION__);
cmd[0].header.cmd_type = R300_CMD_PACKET3;
cmd[0].header.pad0 = R300_CMD_PACKET3_RAW;
@@ -642,44 +574,8 @@ void r300EmitWait(r300ContextPtr rmesa, GLuint flags)
assert(!(flags & ~(R300_WAIT_2D | R300_WAIT_3D)));
cmd = (drm_r300_cmd_header_t *) r300AllocCmdBuf(rmesa, 1,
__FUNCTION__);
cmd = (drm_r300_cmd_header_t *) r300AllocCmdBuf(rmesa, 1, __FUNCTION__);
cmd[0].u = 0;
cmd[0].wait.cmd_type = R300_CMD_WAIT;
cmd[0].wait.flags = flags;
}
void r300EmitAOS(r300ContextPtr rmesa, GLuint nr, GLuint offset)
{
int sz = 1 + (nr >> 1) * 3 + (nr & 1) * 2;
int i;
int cmd_reserved = 0;
int cmd_written = 0;
drm_radeon_cmd_header_t *cmd = NULL;
if (RADEON_DEBUG & DEBUG_VERTS)
fprintf(stderr, "%s: nr=%d, ofs=0x%08x\n", __func__, nr, offset);
start_packet3(RADEON_CP_PACKET3_3D_LOAD_VBPNTR, sz-1);
e32(nr);
for(i=0;i+1<nr;i+=2){
e32( (rmesa->state.aos[i].aos_size << 0)
|(rmesa->state.aos[i].aos_stride << 8)
|(rmesa->state.aos[i+1].aos_size << 16)
|(rmesa->state.aos[i+1].aos_stride << 24)
);
e32(rmesa->state.aos[i].aos_offset +
offset*4*rmesa->state.aos[i].aos_stride);
e32(rmesa->state.aos[i+1].aos_offset +
offset*4*rmesa->state.aos[i+1].aos_stride);
}
if(nr & 1){
e32( (rmesa->state.aos[nr-1].aos_size << 0)
|(rmesa->state.aos[nr-1].aos_stride << 8)
);
e32(rmesa->state.aos[nr-1].aos_offset +
offset*4*rmesa->state.aos[nr-1].aos_stride);
}
}

View File

@@ -27,9 +27,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
/*
* Authors:
* Nicolai Haehnle <prefect_@gmx.net>
/**
* \file
*
* \author Nicolai Haehnle <prefect_@gmx.net>
*/
#ifndef __R300_CMDBUF_H__
@@ -37,24 +38,22 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r300_context.h"
extern int r300FlushCmdBufLocked(r300ContextPtr r300, const char* caller);
extern int r300FlushCmdBuf(r300ContextPtr r300, const char* caller);
extern int r300FlushCmdBufLocked(r300ContextPtr r300, const char *caller);
extern int r300FlushCmdBuf(r300ContextPtr r300, const char *caller);
extern void r300EmitState(r300ContextPtr r300);
extern void r300InitCmdBuf(r300ContextPtr r300);
extern void r300DestroyCmdBuf(r300ContextPtr r300);
extern void r300EmitAOS(r300ContextPtr rmesa, GLuint nr, GLuint offset);
/**
* Make sure that enough space is available in the command buffer
* by flushing if necessary.
*
* \param dwords The number of dwords we need to be free on the command buffer
*/
static __inline__ void r300EnsureCmdBufSpace(r300ContextPtr r300,
int dwords, const char* caller)
int dwords, const char *caller)
{
assert(dwords < r300->cmdbuf.size);
@@ -62,7 +61,6 @@ static __inline__ void r300EnsureCmdBufSpace(r300ContextPtr r300,
r300FlushCmdBuf(r300, caller);
}
/**
* Allocate the given number of dwords in the command buffer and return
* a pointer to the allocated area.
@@ -70,10 +68,10 @@ static __inline__ void r300EnsureCmdBufSpace(r300ContextPtr r300,
* causes state reemission after a flush. This is necessary to ensure
* correct hardware state after an unlock.
*/
static __inline__ uint32_t* r300RawAllocCmdBuf(r300ContextPtr r300,
int dwords, const char* caller)
static __inline__ uint32_t *r300RawAllocCmdBuf(r300ContextPtr r300,
int dwords, const char *caller)
{
uint32_t* ptr;
uint32_t *ptr;
r300EnsureCmdBufSpace(r300, dwords, caller);
@@ -82,17 +80,17 @@ static __inline__ uint32_t* r300RawAllocCmdBuf(r300ContextPtr r300,
return ptr;
}
static __inline__ uint32_t* r300AllocCmdBuf(r300ContextPtr r300,
int dwords, const char* caller)
static __inline__ uint32_t *r300AllocCmdBuf(r300ContextPtr r300,
int dwords, const char *caller)
{
uint32_t* ptr;
uint32_t *ptr;
r300EnsureCmdBufSpace(r300, dwords, caller);
if (!r300->cmdbuf.count_used) {
if (RADEON_DEBUG & DEBUG_IOCTL)
fprintf(stderr, "Reemit state after flush (from %s)\n",
caller);
fprintf(stderr,
"Reemit state after flush (from %s)\n", caller);
r300EmitState(r300);
}
@@ -102,17 +100,17 @@ static __inline__ uint32_t* r300AllocCmdBuf(r300ContextPtr r300,
}
extern void r300EmitBlit(r300ContextPtr rmesa,
GLuint color_fmt,
GLuint src_pitch,
GLuint src_offset,
GLuint dst_pitch,
GLuint dst_offset,
GLint srcx, GLint srcy,
GLint dstx, GLint dsty, GLuint w, GLuint h);
GLuint color_fmt,
GLuint src_pitch,
GLuint src_offset,
GLuint dst_pitch,
GLuint dst_offset,
GLint srcx, GLint srcy,
GLint dstx, GLint dsty, GLuint w, GLuint h);
extern void r300EmitWait(r300ContextPtr rmesa, GLuint flags);
extern void r300EmitLOAD_VBPNTR(r300ContextPtr rmesa, int start);
extern void r300EmitVertexShader(r300ContextPtr rmesa);
extern void r300EmitPixelShader(r300ContextPtr rmesa);
#endif /* __R300_CMDBUF_H__ */
#endif /* __R300_CMDBUF_H__ */

View File

@@ -27,11 +27,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
/*
* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
* Nicolai Haehnle <prefect_@gmx.net>
/**
* \file
*
* \author Keith Whitwell <keith@tungstengraphics.com>
*
* \author Nicolai Haehnle <prefect_@gmx.net>
*/
#include "glheader.h"
#include "api_arrayelt.h"
#include "context.h"
@@ -59,10 +62,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r300_state.h"
#include "r300_ioctl.h"
#include "r300_tex.h"
#include "r300_maos.h"
#include "r300_emit.h"
#ifdef USER_BUFFERS
#include "radeon_mm.h"
#include "r300_mem.h"
#endif
#include "vblank.h"
@@ -70,8 +73,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "xmlpool.h" /* for symbolic values of enum-type options */
/* hw_tcl_on derives from future_hw_tcl_on when its safe to change it. */
int future_hw_tcl_on=1;
int hw_tcl_on=1;
int future_hw_tcl_on = 1;
int hw_tcl_on = 1;
#define need_GL_EXT_stencil_two_side
#define need_GL_ARB_multisample
@@ -88,6 +91,7 @@ int hw_tcl_on=1;
#include "extension_helper.h"
const struct dri_extension card_extensions[] = {
/* *INDENT-OFF* */
{"GL_ARB_multisample", GL_ARB_multisample_functions},
{"GL_ARB_multitexture", NULL},
{"GL_ARB_texture_border_clamp", NULL},
@@ -126,6 +130,7 @@ const struct dri_extension card_extensions[] = {
{"GL_NV_vertex_program", GL_NV_vertex_program_functions},
{"GL_SGIS_generate_mipmap", NULL},
{NULL, NULL}
/* *INDENT-ON* */
};
extern struct tnl_pipeline_stage _r300_render_stage;
@@ -164,7 +169,6 @@ static const struct tnl_pipeline_stage *r300_pipeline[] = {
0,
};
/* Create the device specific rendering context.
*/
GLboolean r300CreateContext(const __GLcontextModes * glVisual,
@@ -183,10 +187,13 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
assert(screen);
/* Allocate the R300 context */
r300 = (r300ContextPtr)CALLOC(sizeof(*r300));
r300 = (r300ContextPtr) CALLOC(sizeof(*r300));
if (!r300)
return GL_FALSE;
if (!(screen->chip_flags & RADEON_CHIPSET_TCL))
hw_tcl_on = future_hw_tcl_on = 0;
/* Parse configuration files.
* Do this here so that initialMaxAnisotropy is set before we create
* the default textures.
@@ -196,8 +203,6 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
r300->initialMaxAnisotropy = driQueryOptionf(&r300->radeon.optionCache,
"def_max_anisotropy");
//r300->texmicrotile = GL_TRUE;
/* Init default driver functions then plug in our R300-specific functions
* (the texture functions are especially important)
*/
@@ -208,21 +213,19 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
r300InitShaderFuncs(&functions);
#ifdef USER_BUFFERS
radeon_mm_init(r300);
#endif
#ifdef HW_VBOS
if (hw_tcl_on) {
r300_init_vbo_funcs(&functions);
}
r300_mem_init(r300);
#endif
if (!radeonInitContext(&r300->radeon, &functions,
glVisual, driContextPriv, sharedContextPrivate)) {
glVisual, driContextPriv,
sharedContextPrivate)) {
FREE(r300);
return GL_FALSE;
}
/* Init r300 context data */
r300->dma.buf0_address = r300->radeon.radeonScreen->buffers->list[0].address;
r300->dma.buf0_address =
r300->radeon.radeonScreen->buffers->list[0].address;
(void)memset(r300->texture_heaps, 0, sizeof(r300->texture_heaps));
make_empty_list(&r300->swapped);
@@ -230,6 +233,7 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
r300->nr_heaps = 1 /* screen->numTexHeaps */ ;
assert(r300->nr_heaps < RADEON_NR_TEX_HEAPS);
for (i = 0; i < r300->nr_heaps; i++) {
/* *INDENT-OFF* */
r300->texture_heaps[i] = driCreateTextureHeap(i, r300,
screen->
texSize[i], 12,
@@ -245,9 +249,10 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
(destroy_texture_object_t
*)
r300DestroyTexObj);
/* *INDENT-ON* */
}
r300->texture_depth = driQueryOptioni(&r300->radeon.optionCache,
"texture_depth");
"texture_depth");
if (r300->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
r300->texture_depth = (screen->cpp == 4) ?
DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;
@@ -259,12 +264,13 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
ctx = r300->radeon.glCtx;
ctx->Const.MaxTextureImageUnits = driQueryOptioni(&r300->radeon.optionCache,
"texture_image_units");
ctx->Const.MaxTextureCoordUnits = driQueryOptioni(&r300->radeon.optionCache,
"texture_coord_units");
ctx->Const.MaxTextureUnits = MIN2(ctx->Const.MaxTextureImageUnits,
ctx->Const.MaxTextureCoordUnits);
ctx->Const.MaxTextureImageUnits =
driQueryOptioni(&r300->radeon.optionCache, "texture_image_units");
ctx->Const.MaxTextureCoordUnits =
driQueryOptioni(&r300->radeon.optionCache, "texture_coord_units");
ctx->Const.MaxTextureUnits =
MIN2(ctx->Const.MaxTextureImageUnits,
ctx->Const.MaxTextureCoordUnits);
ctx->Const.MaxTextureMaxAnisotropy = 16.0;
ctx->Const.MinPointSize = 1.0;
@@ -280,7 +286,8 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
#ifdef USER_BUFFERS
/* Needs further modifications */
#if 0
ctx->Const.MaxArrayLockSize = (/*512*/RADEON_BUFFER_SIZE*16*1024) / (4*4);
ctx->Const.MaxArrayLockSize =
( /*512 */ RADEON_BUFFER_SIZE * 16 * 1024) / (4 * 4);
#endif
#endif
@@ -310,54 +317,53 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
_tnl_allow_vertex_fog(ctx, GL_TRUE);
/* currently bogus data */
ctx->Const.VertexProgram.MaxInstructions=VSF_MAX_FRAGMENT_LENGTH/4;
ctx->Const.VertexProgram.MaxNativeInstructions=VSF_MAX_FRAGMENT_LENGTH/4;
ctx->Const.VertexProgram.MaxNativeAttribs=16; /* r420 */
ctx->Const.VertexProgram.MaxTemps=32;
ctx->Const.VertexProgram.MaxNativeTemps=/*VSF_MAX_FRAGMENT_TEMPS*/32;
ctx->Const.VertexProgram.MaxNativeParameters=256; /* r420 */
ctx->Const.VertexProgram.MaxNativeAddressRegs=1;
ctx->Const.VertexProgram.MaxInstructions = VSF_MAX_FRAGMENT_LENGTH / 4;
ctx->Const.VertexProgram.MaxNativeInstructions =
VSF_MAX_FRAGMENT_LENGTH / 4;
ctx->Const.VertexProgram.MaxNativeAttribs = 16; /* r420 */
ctx->Const.VertexProgram.MaxTemps = 32;
ctx->Const.VertexProgram.MaxNativeTemps =
/*VSF_MAX_FRAGMENT_TEMPS */ 32;
ctx->Const.VertexProgram.MaxNativeParameters = 256; /* r420 */
ctx->Const.VertexProgram.MaxNativeAddressRegs = 1;
ctx->Const.FragmentProgram.MaxNativeTemps = PFS_NUM_TEMP_REGS;
ctx->Const.FragmentProgram.MaxNativeAttribs = 11; /* copy i915... */
ctx->Const.FragmentProgram.MaxNativeAttribs = 11; /* copy i915... */
ctx->Const.FragmentProgram.MaxNativeParameters = PFS_NUM_CONST_REGS;
ctx->Const.FragmentProgram.MaxNativeAluInstructions = PFS_MAX_ALU_INST;
ctx->Const.FragmentProgram.MaxNativeTexInstructions = PFS_MAX_TEX_INST;
ctx->Const.FragmentProgram.MaxNativeInstructions = PFS_MAX_ALU_INST+PFS_MAX_TEX_INST;
ctx->Const.FragmentProgram.MaxNativeTexIndirections = PFS_MAX_TEX_INDIRECT;
ctx->Const.FragmentProgram.MaxNativeAddressRegs = 0; /* and these are?? */
ctx->Const.FragmentProgram.MaxNativeInstructions =
PFS_MAX_ALU_INST + PFS_MAX_TEX_INST;
ctx->Const.FragmentProgram.MaxNativeTexIndirections =
PFS_MAX_TEX_INDIRECT;
ctx->Const.FragmentProgram.MaxNativeAddressRegs = 0; /* and these are?? */
_tnl_ProgramCacheInit(ctx);
ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
driInitExtensions(ctx, card_extensions, GL_TRUE);
if (driQueryOptionb(&r300->radeon.optionCache, "disable_stencil_two_side"))
_mesa_disable_extension(ctx, "GL_EXT_stencil_two_side");
if (driQueryOptionb
(&r300->radeon.optionCache, "disable_stencil_two_side"))
_mesa_disable_extension(ctx, "GL_EXT_stencil_two_side");
if (r300->radeon.glCtx->Mesa_DXTn && !driQueryOptionb (&r300->radeon.optionCache, "disable_s3tc")) {
_mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
_mesa_enable_extension( ctx, "GL_S3_s3tc" );
}
else if (driQueryOptionb (&r300->radeon.optionCache, "force_s3tc_enable")) {
_mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
if (r300->radeon.glCtx->Mesa_DXTn
&& !driQueryOptionb(&r300->radeon.optionCache, "disable_s3tc")) {
_mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
_mesa_enable_extension(ctx, "GL_S3_s3tc");
} else
if (driQueryOptionb(&r300->radeon.optionCache, "force_s3tc_enable"))
{
_mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
}
r300->disable_lowimpact_fallback = driQueryOptionb(&r300->radeon.optionCache, "disable_lowimpact_fallback");
r300->disable_lowimpact_fallback =
driQueryOptionb(&r300->radeon.optionCache,
"disable_lowimpact_fallback");
radeonInitSpanFuncs(ctx);
r300InitCmdBuf(r300);
r300InitState(r300);
#ifdef RADEON_VTXFMT_A
radeon_init_vtxfmt_a(r300);
#endif
#if 0
/* plug in a few more device driver functions */
/* XXX these should really go right after _mesa_init_driver_functions() */
r300InitPixelFuncs(ctx);
r300InitSwtcl(ctx);
#endif
TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline;
tcl_mode = driQueryOptioni(&r300->radeon.optionCache, "tcl_mode");
@@ -370,10 +376,12 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
if (tcl_mode == DRI_CONF_TCL_SW ||
!(r300->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL)) {
if (r300->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL) {
r300->radeon.radeonScreen->chip_flags &= ~RADEON_CHIPSET_TCL;
r300->radeon.radeonScreen->chip_flags &=
~RADEON_CHIPSET_TCL;
fprintf(stderr, "Disabling HW TCL support\n");
}
TCL_FALLBACK(r300->radeon.glCtx, RADEON_TCL_FALLBACK_TCL_DISABLE, 1);
TCL_FALLBACK(r300->radeon.glCtx,
RADEON_TCL_FALLBACK_TCL_DISABLE, 1);
}
return GL_TRUE;
@@ -381,7 +389,7 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
static void r300FreeGartAllocations(r300ContextPtr r300)
{
int i, ret, tries=0, done_age, in_use=0;
int i, ret, tries = 0, done_age, in_use = 0;
drm_radeon_mem_free_t memfree;
memfree.region = RADEON_MEM_REGION_GART;
@@ -401,7 +409,7 @@ static void r300FreeGartAllocations(r300ContextPtr r300)
if (in_use)
r300FlushCmdBuf(r300, __FUNCTION__);
done_age = radeonGetAge((radeonContextPtr)r300);
done_age = radeonGetAge((radeonContextPtr) r300);
for (i = r300->rmm->u_last; i > 0; i--) {
if (r300->rmm->u_list[i].ptr == NULL) {
@@ -416,19 +424,20 @@ static void r300FreeGartAllocations(r300ContextPtr r300)
assert(r300->rmm->u_list[i].h_pending == 0);
tries = 0;
while(r300->rmm->u_list[i].age > done_age && tries++ < 1000) {
while (r300->rmm->u_list[i].age > done_age && tries++ < 1000) {
usleep(10);
done_age = radeonGetAge((radeonContextPtr)r300);
done_age = radeonGetAge((radeonContextPtr) r300);
}
if (tries >= 1000) {
WARN_ONCE("Failed to idle region!");
}
memfree.region_offset = (char *)r300->rmm->u_list[i].ptr -
(char *)r300->radeon.radeonScreen->gartTextures.map;
(char *)r300->radeon.radeonScreen->gartTextures.map;
ret = drmCommandWrite(r300->radeon.radeonScreen->driScreen->fd,
DRM_RADEON_FREE, &memfree, sizeof(memfree));
DRM_RADEON_FREE, &memfree,
sizeof(memfree));
if (ret) {
fprintf(stderr, "Failed to free at %p\nret = %s\n",
r300->rmm->u_list[i].ptr, strerror(-ret));
@@ -438,18 +447,10 @@ static void r300FreeGartAllocations(r300ContextPtr r300)
r300->rmm->u_list[i].pending = 0;
r300->rmm->u_list[i].ptr = NULL;
if (r300->rmm->u_list[i].fb) {
LOCK_HARDWARE(&(r300->radeon));
ret = mmFreeMem(r300->rmm->u_list[i].fb);
UNLOCK_HARDWARE(&(r300->radeon));
if (ret) fprintf(stderr, "failed to free!\n");
r300->rmm->u_list[i].fb = NULL;
}
r300->rmm->u_list[i].ref_count = 0;
}
}
r300->rmm->u_head = i;
#endif /* USER_BUFFERS */
r300->rmm->u_head = i;
#endif /* USER_BUFFERS */
}
/* Destroy the device specific context.
@@ -477,7 +478,8 @@ void r300DestroyContext(__DRIcontextPrivate * driContextPriv)
if (r300) {
GLboolean release_texture_heaps;
release_texture_heaps = (r300->radeon.glCtx->Shared->RefCount == 1);
release_texture_heaps =
(r300->radeon.glCtx->Shared->RefCount == 1);
_swsetup_DestroyContext(r300->radeon.glCtx);
_tnl_ProgramCacheDestroy(r300->radeon.glCtx);
_tnl_DestroyContext(r300->radeon.glCtx);
@@ -485,7 +487,8 @@ void r300DestroyContext(__DRIcontextPrivate * driContextPriv)
_swrast_DestroyContext(r300->radeon.glCtx);
if (r300->dma.current.buf) {
r300ReleaseDmaRegion(r300, &r300->dma.current, __FUNCTION__ );
r300ReleaseDmaRegion(r300, &r300->dma.current,
__FUNCTION__);
#ifndef USER_BUFFERS
r300FlushCmdBuf(r300, __FUNCTION__);
#endif
@@ -518,7 +521,7 @@ void r300DestroyContext(__DRIcontextPrivate * driContextPriv)
/* the memory manager might be accessed when Mesa frees the shared
* state, so don't destroy it earlier
*/
radeon_mm_destroy(r300);
r300_mem_destroy(r300);
#endif
/* free the option cache */

View File

@@ -27,10 +27,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
/*
* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
* Nicolai Haehnle <prefect_@gmx.net>
/**
* \file
*
* \author Keith Whitwell <keith@tungstengraphics.com>
* \author Nicolai Haehnle <prefect_@gmx.net>
*/
#ifndef __R300_CONTEXT_H__
@@ -45,19 +46,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "macros.h"
#include "mtypes.h"
#include "colormac.h"
#include "radeon_context.h"
#define USER_BUFFERS
/* KW: Disable this code. Driver should hook into vbo module
* directly, see i965 driver for example.
*/
/* #define RADEON_VTXFMT_A */
#define HW_VBOS
/* We don't handle 16 bits elts swapping yet */
#ifdef MESA_BIG_ENDIAN
#define FORCE_32BITS_ELTS
#endif
//#define OPTIMIZE_ELTS
@@ -68,13 +58,10 @@ typedef struct r300_context *r300ContextPtr;
#include "radeon_lock.h"
#include "mm.h"
/* Checkpoint.. for convenience */
#define CPT { fprintf(stderr, "%s:%s line %d\n", __FILE__, __FUNCTION__, __LINE__); }
/* From http://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/Variadic-Macros.html .
I suppose we could inline this and use macro to fetch out __LINE__ and stuff in case we run into trouble
with other compilers ... GLUE!
*/
#if 1
#define WARN_ONCE(a, ...) { \
static int warn##__LINE__=1; \
if(warn##__LINE__){ \
@@ -86,32 +73,61 @@ typedef struct r300_context *r300ContextPtr;
warn##__LINE__=0;\
} \
}
#else
#define WARN_ONCE(a, ...) {}
#endif
/* We should probably change types within vertex_shader
and pixel_shader structure later on */
#define CARD32 GLuint
#include "vertex_shader.h"
#include "r300_vertprog.h"
#include "r300_fragprog.h"
#undef CARD32
/**
* This function takes a float and packs it into a uint32_t
*/
static __inline__ uint32_t r300PackFloat32(float fl)
{
union { float fl; uint32_t u; } u;
union {
float fl;
uint32_t u;
} u;
u.fl = fl;
return u.u;
}
/* This is probably wrong for some values, I need to test this
* some more. Range checking would be a good idea also..
*
* But it works for most things. I'll fix it later if someone
* else with a better clue doesn't
*/
static __inline__ uint32_t r300PackFloat24(float f)
{
float mantissa;
int exponent;
uint32_t float24 = 0;
if (f == 0.0)
return 0;
mantissa = frexpf(f, &exponent);
/* Handle -ve */
if (mantissa < 0) {
float24 |= (1 << 23);
mantissa = mantissa * -1.0;
}
/* Handle exponent, bias of 63 */
exponent += 62;
float24 |= (exponent << 16);
/* Kill 7 LSB of mantissa */
float24 |= (r300PackFloat32(mantissa) & 0x7FFFFF) >> 7;
return float24;
}
/************ DMA BUFFERS **************/
/* Need refcounting on dma buffers:
*/
struct r300_dma_buffer {
int refcount; /* the number of retained regions in buf */
int refcount; /**< the number of retained regions in buf */
drmBufPtr buf;
int id;
};
@@ -130,10 +146,10 @@ struct r300_dma_region {
char *address; /* == buf->address */
int start, end, ptr; /* offsets from start of buf */
int aos_offset; /* address in GART memory */
int aos_stride; /* distance between elements, in dwords */
int aos_size; /* number of components (1-4) */
int aos_reg; /* VAP register assignment */
int aos_offset; /* address in GART memory */
int aos_stride; /* distance between elements, in dwords */
int aos_size; /* number of components (1-4) */
int aos_reg; /* VAP register assignment */
};
struct r300_dma {
@@ -175,16 +191,15 @@ struct r300_tex_obj {
drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS];
/* Six, for the cube faces */
GLuint pitch; /* this isn't sent to hardware just used in calculations */
GLuint pitch; /* this isn't sent to hardware just used in calculations */
/* hardware register values */
/* Note that R200 has 8 registers per texture and R300 only 7 */
GLuint filter;
GLuint filter_1;
GLuint pitch_reg;
GLuint size; /* npot only */
GLuint size; /* npot only */
GLuint format;
GLuint offset; /* Image location in the card's address space.
GLuint offset; /* Image location in the card's address space.
All cube faces follow. */
GLuint unknown4;
GLuint unknown5;
@@ -198,10 +213,9 @@ struct r300_tex_obj {
GLuint pp_cubic_faces; /* cube face 1,2,3,4 log2 sizes */
GLuint format_x;
GLboolean border_fallback;
GLuint tile_bits; /* hw texture tile bits used on this texture */
GLuint tile_bits; /* hw texture tile bits used on this texture */
};
struct r300_texture_env_state {
@@ -210,7 +224,6 @@ struct r300_texture_env_state {
GLenum envMode;
};
/* The blit width for texture uploads
*/
#define R300_BLIT_WIDTH_BYTES 1024
@@ -218,7 +231,7 @@ struct r300_texture_env_state {
struct r300_texture_state {
struct r300_texture_env_state unit[R300_MAX_TEXTURE_UNITS];
int tc_count; /* number of incoming texture coordinates from VAP */
int tc_count; /* number of incoming texture coordinates from VAP */
};
/**
@@ -230,16 +243,15 @@ struct r300_texture_state {
*/
struct r300_state_atom {
struct r300_state_atom *next, *prev;
const char* name; /* for debug */
const char *name; /* for debug */
int cmd_size; /* maximum size in dwords */
GLuint idx; /* index in an array (e.g. textures) */
uint32_t* cmd;
uint32_t *cmd;
GLboolean dirty;
int (*check)(r300ContextPtr, struct r300_state_atom* atom);
int (*check) (r300ContextPtr, struct r300_state_atom * atom);
};
#define R300_VPT_CMD_0 0
#define R300_VPT_XSCALE 1
#define R300_VPT_XOFFSET 2
@@ -249,7 +261,7 @@ struct r300_state_atom {
#define R300_VPT_ZOFFSET 6
#define R300_VPT_CMDSIZE 7
#define R300_VIR_CMD_0 0 /* vir is variable size (at least 1) */
#define R300_VIR_CMD_0 0 /* vir is variable size (at least 1) */
#define R300_VIR_CNTL_0 1
#define R300_VIR_CNTL_1 2
#define R300_VIR_CNTL_2 3
@@ -270,7 +282,6 @@ struct r300_state_atom {
#define R300_VOF_CNTL_1 2
#define R300_VOF_CMDSIZE 3
#define R300_PVS_CMD_0 0
#define R300_PVS_CNTL_1 1
#define R300_PVS_CNTL_2 2
@@ -320,7 +331,7 @@ struct r300_state_atom {
#define R300_RI_INTERP_7 8
#define R300_RI_CMDSIZE 9
#define R300_RR_CMD_0 0 /* rr is variable size (at least 1) */
#define R300_RR_CMD_0 0 /* rr is variable size (at least 1) */
#define R300_RR_ROUTE_0 1
#define R300_RR_ROUTE_1 2
#define R300_RR_ROUTE_2 3
@@ -402,11 +413,11 @@ struct r300_state_atom {
#define R300_VPI_CMD_0 0
#define R300_VPI_INSTR_0 1
#define R300_VPI_CMDSIZE 1025 /* 256 16 byte instructions */
#define R300_VPI_CMDSIZE 1025 /* 256 16 byte instructions */
#define R300_VPP_CMD_0 0
#define R300_VPP_PARAM_0 1
#define R300_VPP_CMDSIZE 1025 /* 256 4-component parameters */
#define R300_VPP_CMDSIZE 1025 /* 256 4-component parameters */
#define R300_VPS_CMD_0 0
#define R300_VPS_ZERO_0 1
@@ -428,54 +439,54 @@ struct r300_state_atom {
struct r300_hw_state {
struct r300_state_atom atomlist;
GLboolean is_dirty;
GLboolean all_dirty;
int max_state_size; /* in dwords */
GLboolean is_dirty;
GLboolean all_dirty;
int max_state_size; /* in dwords */
struct r300_state_atom vpt; /* viewport (1D98) */
struct r300_state_atom vap_cntl;
struct r300_state_atom vof; /* VAP output format register 0x2090 */
struct r300_state_atom vof; /* VAP output format register 0x2090 */
struct r300_state_atom vte; /* (20B0) */
struct r300_state_atom unk2134; /* (2134) */
struct r300_state_atom vap_cntl_status;
struct r300_state_atom vir[2]; /* vap input route (2150/21E0) */
struct r300_state_atom vic; /* vap input control (2180) */
struct r300_state_atom unk21DC; /* (21DC) */
struct r300_state_atom unk221C; /* (221C) */
struct r300_state_atom unk2220; /* (2220) */
struct r300_state_atom unk2288; /* (2288) */
struct r300_state_atom unk21DC; /* (21DC) */
struct r300_state_atom unk221C; /* (221C) */
struct r300_state_atom unk2220; /* (2220) */
struct r300_state_atom unk2288; /* (2288) */
struct r300_state_atom pvs; /* pvs_cntl (22D0) */
struct r300_state_atom gb_enable; /* (4008) */
struct r300_state_atom gb_misc; /* Multisampling position shifts ? (4010) */
struct r300_state_atom unk4200; /* (4200) */
struct r300_state_atom unk4214; /* (4214) */
struct r300_state_atom gb_enable; /* (4008) */
struct r300_state_atom gb_misc; /* Multisampling position shifts ? (4010) */
struct r300_state_atom unk4200; /* (4200) */
struct r300_state_atom unk4214; /* (4214) */
struct r300_state_atom ps; /* pointsize (421C) */
struct r300_state_atom unk4230; /* (4230) */
struct r300_state_atom unk4230; /* (4230) */
struct r300_state_atom lcntl; /* line control */
struct r300_state_atom unk4260; /* (4260) */
struct r300_state_atom unk4260; /* (4260) */
struct r300_state_atom shade;
struct r300_state_atom polygon_mode;
struct r300_state_atom fogp; /* fog parameters (4294) */
struct r300_state_atom unk429C; /* (429C) */
struct r300_state_atom unk429C; /* (429C) */
struct r300_state_atom zbias_cntl;
struct r300_state_atom zbs; /* zbias (42A4) */
struct r300_state_atom occlusion_cntl;
struct r300_state_atom cul; /* cull cntl (42B8) */
struct r300_state_atom unk42C0; /* (42C0) */
struct r300_state_atom unk42C0; /* (42C0) */
struct r300_state_atom rc; /* rs control (4300) */
struct r300_state_atom ri; /* rs interpolators (4310) */
struct r300_state_atom rr; /* rs route (4330) */
struct r300_state_atom unk43A4; /* (43A4) */
struct r300_state_atom unk43E8; /* (43E8) */
struct r300_state_atom fp; /* fragment program cntl + nodes (4600) */
struct r300_state_atom fpt; /* texi - (4620) */
struct r300_state_atom fpt; /* texi - (4620) */
struct r300_state_atom unk46A4; /* (46A4) */
struct r300_state_atom fpi[4]; /* fp instructions (46C0/47C0/48C0/49C0) */
struct r300_state_atom fogs; /* fog state (4BC0) */
struct r300_state_atom fogc; /* fog color (4BC8) */
struct r300_state_atom at; /* alpha test (4BD4) */
struct r300_state_atom unk4BD8; /* (4BD8) */
struct r300_state_atom fpp; /* 0x4C00 and following */
struct r300_state_atom fpp; /* 0x4C00 and following */
struct r300_state_atom unk4E00; /* (4E00) */
struct r300_state_atom bld; /* blending (4E04) */
struct r300_state_atom cmk; /* colormask (4E0C) */
@@ -495,11 +506,11 @@ struct r300_hw_state {
struct r300_state_atom vpi; /* vp instructions */
struct r300_state_atom vpp; /* vp parameters */
struct r300_state_atom vps; /* vertex point size (?) */
/* 8 texture units */
/* the state is grouped by function and not by
texture unit. This makes single unit updates
really awkward - we are much better off
updating the whole thing at once */
/* 8 texture units */
/* the state is grouped by function and not by
texture unit. This makes single unit updates
really awkward - we are much better off
updating the whole thing at once */
struct {
struct r300_state_atom filter;
struct r300_state_atom filter_1;
@@ -509,11 +520,10 @@ struct r300_hw_state {
struct r300_state_atom offset;
struct r300_state_atom chroma_key;
struct r300_state_atom border_color;
} tex;
} tex;
struct r300_state_atom txe; /* tex enable (4104) */
};
/**
* This structure holds the command buffer while it is being constructed.
*
@@ -522,13 +532,12 @@ struct r300_hw_state {
* otherwise.
*/
struct r300_cmdbuf {
int size; /* DWORDs allocated for buffer */
uint32_t* cmd_buf;
int count_used; /* DWORDs filled so far */
int count_reemit; /* size of re-emission batch */
int size; /* DWORDs allocated for buffer */
uint32_t *cmd_buf;
int count_used; /* DWORDs filled so far */
int count_reemit; /* size of re-emission batch */
};
/**
* State cache
*/
@@ -560,9 +569,9 @@ struct r300_vertex_shader_fragment {
union {
GLuint d[VSF_MAX_FRAGMENT_LENGTH];
float f[VSF_MAX_FRAGMENT_LENGTH];
VERTEX_SHADER_INSTRUCTION i[VSF_MAX_FRAGMENT_LENGTH/4];
} body;
};
VERTEX_SHADER_INSTRUCTION i[VSF_MAX_FRAGMENT_LENGTH / 4];
} body;
};
#define VSF_DEST_PROGRAM 0x0
#define VSF_DEST_MATRIX0 0x200
@@ -576,24 +585,19 @@ struct r300_vertex_shader_fragment {
struct r300_vertex_shader_state {
struct r300_vertex_shader_fragment program;
/* a bit of a waste - each uses only a subset of allocated space..
but easier to program */
struct r300_vertex_shader_fragment matrix[3];
struct r300_vertex_shader_fragment vector[2];
struct r300_vertex_shader_fragment unknown1;
struct r300_vertex_shader_fragment unknown2;
int program_start;
int unknown_ptr1; /* pointer within program space */
int unknown_ptr1; /* pointer within program space */
int program_end;
int param_offset;
int param_count;
int unknown_ptr2; /* pointer within program space */
int unknown_ptr3; /* pointer within program space */
};
int unknown_ptr2; /* pointer within program space */
int unknown_ptr3; /* pointer within program space */
};
extern int hw_tcl_on;
@@ -603,7 +607,6 @@ extern int hw_tcl_on;
/* Should but doesnt work */
//#define CURRENT_VERTEX_SHADER(ctx) (R300_CONTEXT(ctx)->curr_vp)
/* 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.
*/
@@ -621,7 +624,7 @@ struct r300_vertex_program {
struct r300_vertex_shader_fragment program;
int pos_end;
int num_temporaries; /* Number of temp vars used by program */
int num_temporaries; /* Number of temp vars used by program */
int wpos_idx;
int inputs[VERT_ATTRIB_MAX];
int outputs[VERT_RESULT_MAX];
@@ -631,7 +634,7 @@ struct r300_vertex_program {
};
struct r300_vertex_program_cont {
struct gl_vertex_program mesa_program; /* Must be first */
struct gl_vertex_program mesa_program; /* Must be first */
struct r300_vertex_shader_fragment params;
struct r300_vertex_program *progs;
};
@@ -644,8 +647,8 @@ struct r300_vertex_program_cont {
/* Mapping Mesa registers to R300 temporaries */
struct reg_acc {
int reg; /* Assigned hw temp */
unsigned int refcount; /* Number of uses by mesa program */
int reg; /* Assigned hw temp */
unsigned int refcount; /* Number of uses by mesa program */
};
/**
@@ -676,7 +679,6 @@ struct reg_lifetime {
int scalar_lastread;
};
/**
* Store usage information about an ALU instruction slot during the
* compilation of a fragment program.
@@ -702,7 +704,7 @@ struct r300_pfs_compile_slot {
* Store information during compilation of fragment programs.
*/
struct r300_pfs_compile_state {
int nrslots; /* number of ALU slots used so far */
int nrslots; /* number of ALU slots used so far */
/* Track which (parts of) slots are already filled with instructions */
struct r300_pfs_compile_slot slot[PFS_MAX_ALU_INST];
@@ -713,7 +715,7 @@ struct r300_pfs_compile_state {
/* Used to map Mesa's inputs/temps onto hardware temps */
int temp_in_use;
struct reg_acc temps[PFS_NUM_TEMP_REGS];
struct reg_acc inputs[32]; /* don't actually need 32... */
struct reg_acc inputs[32]; /* don't actually need 32... */
/* Track usage of hardware temps, for register allocation,
* indirection detection, etc. */
@@ -769,7 +771,7 @@ struct r300_fragment_program {
* gl_program_parameter_list::ParameterValues, or a pointer to a
* global constant (e.g. for sin/cos-approximation)
*/
const GLfloat* constant[PFS_NUM_CONST_REGS];
const GLfloat *constant[PFS_NUM_CONST_REGS];
int const_nr;
int max_temp_idx;
@@ -799,30 +801,17 @@ struct radeon_vertex_buffer {
int Count;
void *Elts;
int elt_size;
int elt_min, elt_max; /* debug */
int elt_min, elt_max; /* debug */
struct dt AttribPtr[VERT_ATTRIB_MAX];
const struct _mesa_prim *Primitive;
GLuint PrimitiveCount;
const struct _mesa_prim *Primitive;
GLuint PrimitiveCount;
GLint LockFirst;
GLsizei LockCount;
int lock_uptodate;
};
struct r300_aos_rec {
GLuint offset;
int element_size; /* in dwords */
int stride; /* distance between elements, in dwords */
int format;
int ncomponents; /* number of components - between 1 and 4, inclusive */
int reg; /* which register they are assigned to. */
};
struct r300_state {
struct r300_depthbuffer_state depth;
struct r300_texture_state texture;
@@ -836,12 +825,12 @@ struct r300_state {
GLuint *Elts;
struct r300_dma_region elt_dma;
DECLARE_RENDERINPUTS(render_inputs_bitset); /* actual render inputs that R300 was configured for.
They are the same as tnl->render_inputs for fixed pipeline */
DECLARE_RENDERINPUTS(render_inputs_bitset); /* actual render inputs that R300 was configured for.
They are the same as tnl->render_inputs for fixed pipeline */
struct {
int transform_offset; /* Transform matrix offset, -1 if none */
} vap_param; /* vertex processor parameter allocation - tells where to write parameters */
int transform_offset; /* Transform matrix offset, -1 if none */
} vap_param; /* vertex processor parameter allocation - tells where to write parameters */
struct r300_stencilbuffer_state stencil;
@@ -852,10 +841,10 @@ struct r300_state {
#define R300_FALLBACK_RAST 2
/**
* R300 context structure.
* \brief R300 context structure.
*/
struct r300_context {
struct radeon_context radeon; /* parent class, must be first */
struct radeon_context radeon; /* parent class, must be first */
struct r300_hw_state hw;
struct r300_cmdbuf cmdbuf;
@@ -882,13 +871,12 @@ struct r300_context {
GLuint prefer_gart_client_texturing;
#ifdef USER_BUFFERS
struct radeon_memory_manager *rmm;
GLvector4f dummy_attrib[_TNL_ATTRIB_MAX];
GLvector4f *temp_attrib[_TNL_ATTRIB_MAX];
struct r300_memory_manager *rmm;
#endif
GLboolean texmicrotile;
GLboolean span_dlocking;
GLvector4f dummy_attrib[_TNL_ATTRIB_MAX];
GLvector4f *temp_attrib[_TNL_ATTRIB_MAX];
GLboolean disable_lowimpact_fallback;
};
@@ -899,42 +887,16 @@ struct r300_buffer_object {
#define R300_CONTEXT(ctx) ((r300ContextPtr)(ctx->DriverCtx))
static __inline GLuint r300PackColor( GLuint cpp,
GLubyte r, GLubyte g,
GLubyte b, GLubyte a )
{
switch ( cpp ) {
case 2:
return PACK_COLOR_565( r, g, b );
case 4:
return PACK_COLOR_8888( r, g, b, a );
default:
return 0;
}
}
extern void r300DestroyContext(__DRIcontextPrivate * driContextPriv);
extern GLboolean r300CreateContext(const __GLcontextModes * glVisual,
__DRIcontextPrivate * driContextPriv,
void *sharedContextPrivate);
extern int r300_get_num_verts(r300ContextPtr rmesa, int num_verts, int prim);
extern void r300_select_vertex_shader(r300ContextPtr r300);
extern void r300SelectVertexShader(r300ContextPtr r300);
extern void r300InitShaderFuncs(struct dd_function_table *functions);
extern int r300VertexProgUpdateParams(GLcontext *ctx, struct r300_vertex_program_cont *vp, float *dst);
extern int r300Fallback(GLcontext *ctx);
extern void radeon_vb_to_rvb(r300ContextPtr rmesa, struct radeon_vertex_buffer *rvb, struct vertex_buffer *vb);
extern GLboolean r300_run_vb_render(GLcontext *ctx, struct tnl_pipeline_stage *stage);
#ifdef RADEON_VTXFMT_A
extern void radeon_init_vtxfmt_a(r300ContextPtr rmesa);
#endif
#ifdef HW_VBOS
extern void r300_init_vbo_funcs(struct dd_function_table *functions);
extern void r300_evict_vbos(GLcontext *ctx, int amount);
#endif
extern int r300VertexProgUpdateParams(GLcontext * ctx,
struct r300_vertex_program_cont *vp,
float *dst);
#define RADEON_D_CAPTURE 0
#define RADEON_D_PLAYBACK 1

View File

@@ -27,9 +27,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
/*
* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
/**
* \file
*
* \author Keith Whitwell <keith@tungstengraphics.com>
*/
#include "glheader.h"
@@ -47,11 +48,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r300_context.h"
#include "radeon_ioctl.h"
#include "r300_state.h"
#include "r300_maos.h"
#include "r300_emit.h"
#include "r300_ioctl.h"
#ifdef USER_BUFFERS
#include "radeon_mm.h"
#include "r300_mem.h"
#endif
#if SWIZZLE_X != R300_INPUT_ROUTE_SELECT_X || \
@@ -65,7 +66,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define DEBUG_ALL DEBUG_VERTS
#if defined(USE_X86_ASM)
#define COPY_DWORDS( dst, src, nr ) \
do { \
@@ -86,9 +86,9 @@ do { \
} while (0)
#endif
static void emit_vec4(GLcontext * ctx,
struct r300_dma_region *rvb,
GLvoid *data, int stride, int count)
static void r300EmitVec4(GLcontext * ctx,
struct r300_dma_region *rvb,
GLvoid * data, int stride, int count)
{
int i;
int *out = (int *)(rvb->address + rvb->start);
@@ -107,9 +107,9 @@ static void emit_vec4(GLcontext * ctx,
}
}
static void emit_vec8(GLcontext * ctx,
struct r300_dma_region *rvb,
GLvoid *data, int stride, int count)
static void r300EmitVec8(GLcontext * ctx,
struct r300_dma_region *rvb,
GLvoid * data, int stride, int count)
{
int i;
int *out = (int *)(rvb->address + rvb->start);
@@ -129,9 +129,9 @@ static void emit_vec8(GLcontext * ctx,
}
}
static void emit_vec12(GLcontext * ctx,
struct r300_dma_region *rvb,
GLvoid *data, int stride, int count)
static void r300EmitVec12(GLcontext * ctx,
struct r300_dma_region *rvb,
GLvoid * data, int stride, int count)
{
int i;
int *out = (int *)(rvb->address + rvb->start);
@@ -152,9 +152,9 @@ static void emit_vec12(GLcontext * ctx,
}
}
static void emit_vec16(GLcontext * ctx,
struct r300_dma_region *rvb,
GLvoid *data, int stride, int count)
static void r300EmitVec16(GLcontext * ctx,
struct r300_dma_region *rvb,
GLvoid * data, int stride, int count)
{
int i;
int *out = (int *)(rvb->address + rvb->start);
@@ -176,9 +176,9 @@ static void emit_vec16(GLcontext * ctx,
}
}
static void emit_vector(GLcontext * ctx,
static void r300EmitVec(GLcontext * ctx,
struct r300_dma_region *rvb,
GLvoid *data, int size, int stride, int count)
GLvoid * data, int size, int stride, int count)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
@@ -186,86 +186,57 @@ static void emit_vector(GLcontext * ctx,
fprintf(stderr, "%s count %d size %d stride %d\n",
__FUNCTION__, count, size, stride);
/* Gets triggered when playing with future_hw_tcl_on ...*/
/* Gets triggered when playing with future_hw_tcl_on ... */
//assert(!rvb->buf);
if (stride == 0) {
r300AllocDmaRegion(rmesa, rvb, size * 4, 4);
count = 1;
rvb->aos_offset = GET_START(rvb);
rvb->aos_stride = 0;
rvb->aos_offset = GET_START(rvb);
rvb->aos_stride = 0;
} else {
r300AllocDmaRegion(rmesa, rvb, size * count * 4, 4); /* alignment? */
rvb->aos_offset = GET_START(rvb);
rvb->aos_stride = size;
rvb->aos_offset = GET_START(rvb);
rvb->aos_stride = size;
}
/* Emit the data
*/
switch (size) {
case 1:
emit_vec4(ctx, rvb, data, stride, count);
r300EmitVec4(ctx, rvb, data, stride, count);
break;
case 2:
emit_vec8(ctx, rvb, data, stride, count);
r300EmitVec8(ctx, rvb, data, stride, count);
break;
case 3:
emit_vec12(ctx, rvb, data, stride, count);
r300EmitVec12(ctx, rvb, data, stride, count);
break;
case 4:
emit_vec16(ctx, rvb, data, stride, count);
r300EmitVec16(ctx, rvb, data, stride, count);
break;
default:
assert(0);
exit(1);
_mesa_exit(-1);
break;
}
}
void r300EmitElts(GLcontext * ctx, void *elts, unsigned long n_elts, int elt_size)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct r300_dma_region *rvb=&rmesa->state.elt_dma;
void *out;
assert(elt_size == 2 || elt_size == 4);
if(r300IsGartMemory(rmesa, elts, n_elts * elt_size)){
rvb->address = rmesa->radeon.radeonScreen->gartTextures.map;
rvb->start = ((char *)elts) - rvb->address;
rvb->aos_offset = rmesa->radeon.radeonScreen->gart_texture_offset + rvb->start;
return ;
}else if(r300IsGartMemory(rmesa, elts, 1)){
WARN_ONCE("Pointer not within GART memory!\n");
exit(1);
}
r300AllocDmaRegion(rmesa, rvb, n_elts * elt_size, elt_size);
rvb->aos_offset = GET_START(rvb);
out = rvb->address + rvb->start;
memcpy(out, elts, n_elts * elt_size);
}
static GLuint t_type(struct dt *dt)
{
switch (dt->type) {
case GL_UNSIGNED_BYTE:
return AOS_FORMAT_UBYTE;
case GL_SHORT:
return AOS_FORMAT_USHORT;
case GL_FLOAT:
return AOS_FORMAT_FLOAT;
default:
assert(0);
break;
break;
}
return AOS_FORMAT_FLOAT;
}
@@ -274,18 +245,15 @@ static GLuint t_vir0_size(struct dt *dt)
switch (dt->type) {
case GL_UNSIGNED_BYTE:
return 4;
case GL_SHORT:
return 7;
case GL_FLOAT:
return dt->size - 1;
default:
assert(0);
break;
break;
}
return 0;
}
@@ -294,65 +262,72 @@ static GLuint t_aos_size(struct dt *dt)
switch (dt->type) {
case GL_UNSIGNED_BYTE:
return 1;
case GL_SHORT:
return 2;
case GL_FLOAT:
return dt->size;
default:
assert(0);
break;
}
return 0;
}
static GLuint t_vir0(uint32_t *dst, struct dt *dt, int *inputs, GLint *tab, GLuint nr)
static GLuint t_vir0(uint32_t * dst, struct dt *dt, int *inputs,
GLint * tab, GLuint nr)
{
GLuint i, dw;
for (i = 0; i + 1 < nr; i += 2){
dw = t_vir0_size(&dt[tab[i]]) | (inputs[tab[i]] << 8) | (t_type(&dt[tab[i]]) << 14);
dw |= (t_vir0_size(&dt[tab[i + 1]]) | (inputs[tab[i + 1]] << 8) | (t_type(&dt[tab[i + 1]]) << 14)) << 16;
for (i = 0; i + 1 < nr; i += 2) {
dw = t_vir0_size(&dt[tab[i]]) | (inputs[tab[i]] << 8) |
(t_type(&dt[tab[i]]) << 14);
dw |=
(t_vir0_size(&dt[tab[i + 1]]) |
(inputs[tab[i + 1]] << 8) | (t_type(&dt[tab[i + 1]])
<< 14)) << 16;
if (i + 2 == nr) {
dw |= (1 << (13 + 16));
}
dst[i >> 1] = dw;
}
if (nr & 1) {
dw = t_vir0_size(&dt[tab[nr - 1]]) | (inputs[tab[nr - 1]] << 8) | (t_type(&dt[tab[nr - 1]]) << 14);
dw = t_vir0_size(&dt[tab[nr - 1]]) | (inputs[tab[nr - 1]]
<< 8) |
(t_type(&dt[tab[nr - 1]]) << 14);
dw |= 1 << 13;
dst[nr >> 1] = dw;
}
return (nr + 1) >> 1;
}
static GLuint t_swizzle(int swizzle[4])
{
return (swizzle[0] << R300_INPUT_ROUTE_X_SHIFT) |
(swizzle[1] << R300_INPUT_ROUTE_Y_SHIFT) |
(swizzle[2] << R300_INPUT_ROUTE_Z_SHIFT) |
(swizzle[3] << R300_INPUT_ROUTE_W_SHIFT);
(swizzle[1] << R300_INPUT_ROUTE_Y_SHIFT) |
(swizzle[2] << R300_INPUT_ROUTE_Z_SHIFT) |
(swizzle[3] << R300_INPUT_ROUTE_W_SHIFT);
}
static GLuint t_vir1(uint32_t *dst, int swizzle[][4], GLuint nr)
static GLuint t_vir1(uint32_t * dst, int swizzle[][4], GLuint nr)
{
GLuint i;
for (i = 0; i + 1 < nr; i += 2) {
dst[i >> 1] = t_swizzle(swizzle[i]) | R300_INPUT_ROUTE_ENABLE;
dst[i >> 1] |= (t_swizzle(swizzle[i + 1]) | R300_INPUT_ROUTE_ENABLE) << 16;
dst[i >> 1] |=
(t_swizzle(swizzle[i + 1]) | R300_INPUT_ROUTE_ENABLE)
<< 16;
}
if (nr & 1)
dst[nr >> 1] = t_swizzle(swizzle[nr - 1]) | R300_INPUT_ROUTE_ENABLE;
dst[nr >> 1] =
t_swizzle(swizzle[nr - 1]) | R300_INPUT_ROUTE_ENABLE;
return (nr + 1) >> 1;
}
@@ -365,23 +340,23 @@ static GLuint t_vic(GLcontext * ctx, GLuint InputsRead)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
GLuint i, vic_1 = 0;
if (InputsRead & (1 << VERT_ATTRIB_POS))
vic_1 |= R300_INPUT_CNTL_POS;
if (InputsRead & (1 << VERT_ATTRIB_NORMAL))
vic_1 |= R300_INPUT_CNTL_NORMAL;
if (InputsRead & (1 << VERT_ATTRIB_COLOR0))
vic_1 |= R300_INPUT_CNTL_COLOR;
r300->state.texture.tc_count = 0;
for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
if (InputsRead & (1 << (VERT_ATTRIB_TEX0 + i))) {
r300->state.texture.tc_count++;
vic_1 |= R300_INPUT_CNTL_TC0 << i;
}
return vic_1;
}
@@ -390,7 +365,7 @@ static GLuint t_vic(GLcontext * ctx, GLuint InputsRead)
* This function should never return R300_FALLBACK_TCL when using software tcl.
*/
int r300EmitArrays(GLcontext *ctx)
int r300EmitArrays(GLcontext * ctx)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
r300ContextPtr r300 = rmesa;
@@ -400,71 +375,100 @@ int r300EmitArrays(GLcontext *ctx)
GLuint i;
GLuint InputsRead = 0, OutputsWritten = 0;
int *inputs = NULL;
int vir_inputs[VERT_ATTRIB_MAX];
GLint tab[VERT_ATTRIB_MAX];
int swizzle[VERT_ATTRIB_MAX][4];
if (hw_tcl_on) {
struct r300_vertex_program *prog=(struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx);
struct r300_vertex_program *prog =
(struct r300_vertex_program *)
CURRENT_VERTEX_SHADER(ctx);
inputs = prog->inputs;
InputsRead = CURRENT_VERTEX_SHADER(ctx)->key.InputsRead;
OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->key.OutputsWritten;
} else {
DECLARE_RENDERINPUTS(inputs_bitset);
inputs = r300->state.sw_tcl_inputs;
RENDERINPUTS_COPY( inputs_bitset, TNL_CONTEXT(ctx)->render_inputs_bitset );
assert(RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_POS ));
RENDERINPUTS_COPY(inputs_bitset,
TNL_CONTEXT(ctx)->render_inputs_bitset);
assert(RENDERINPUTS_TEST(inputs_bitset, _TNL_ATTRIB_POS));
InputsRead |= 1 << VERT_ATTRIB_POS;
OutputsWritten |= 1 << VERT_RESULT_HPOS;
assert(RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_NORMAL ) == 0);
assert(RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_COLOR0 ));
assert(RENDERINPUTS_TEST(inputs_bitset, _TNL_ATTRIB_NORMAL)
== 0);
assert(RENDERINPUTS_TEST(inputs_bitset, _TNL_ATTRIB_COLOR0));
InputsRead |= 1 << VERT_ATTRIB_COLOR0;
OutputsWritten |= 1 << VERT_RESULT_COL0;
if (RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_COLOR1 )) {
if (RENDERINPUTS_TEST(inputs_bitset, _TNL_ATTRIB_COLOR1)) {
InputsRead |= 1 << VERT_ATTRIB_COLOR1;
OutputsWritten |= 1 << VERT_RESULT_COL1;
}
for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
if (RENDERINPUTS_TEST( inputs_bitset, _TNL_ATTRIB_TEX(i) )) {
if (RENDERINPUTS_TEST
(inputs_bitset, _TNL_ATTRIB_TEX(i))) {
InputsRead |= 1 << (VERT_ATTRIB_TEX0 + i);
OutputsWritten |= 1 << (VERT_RESULT_TEX0 + i);
}
for (i = 0, nr = 0; i < VERT_ATTRIB_MAX; i++)
if (InputsRead & (1 << i))
inputs[i] = nr++;
else
inputs[i] = -1;
RENDERINPUTS_COPY( rmesa->state.render_inputs_bitset, inputs_bitset );
if (!
(r300->radeon.radeonScreen->
chip_flags & RADEON_CHIPSET_TCL)) {
/* Fixed, apply to vir0 only */
memcpy(vir_inputs, inputs,
VERT_ATTRIB_MAX * sizeof(int));
inputs = vir_inputs;
if (InputsRead & VERT_ATTRIB_POS)
inputs[VERT_ATTRIB_POS] = 0;
if (InputsRead & (1 << VERT_ATTRIB_COLOR0))
inputs[VERT_ATTRIB_COLOR0] = 2;
if (InputsRead & (1 << VERT_ATTRIB_COLOR1))
inputs[VERT_ATTRIB_COLOR1] = 3;
for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX7; i++)
if (InputsRead & (1 << i))
inputs[i] = 6 + (i - VERT_ATTRIB_TEX0);
}
RENDERINPUTS_COPY(rmesa->state.render_inputs_bitset,
inputs_bitset);
}
assert(InputsRead);
assert(OutputsWritten);
for (i = 0, nr = 0; i < VERT_ATTRIB_MAX; i++)
if (InputsRead & (1 << i))
tab[nr++] = i;
if (nr > R300_MAX_AOS_ARRAYS)
return R300_FALLBACK_TCL;
for (i = 0; i < nr; i++) {
int ci;
int comp_size, fix, found = 0;
swizzle[i][0] = SWIZZLE_ZERO;
swizzle[i][1] = SWIZZLE_ZERO;
swizzle[i][2] = SWIZZLE_ZERO;
swizzle[i][3] = SWIZZLE_ONE;
for (ci = 0; ci < VB->AttribPtr[tab[i]].size; ci++)
swizzle[i][ci] = ci;
#if MESA_BIG_ENDIAN
#define SWAP_INT(a, b) do { \
int __temp; \
@@ -472,107 +476,126 @@ int r300EmitArrays(GLcontext *ctx)
a = b; \
b = __temp; \
} while (0)
if (VB->AttribPtr[tab[i]].type == GL_UNSIGNED_BYTE) {
SWAP_INT(swizzle[i][0], swizzle[i][3]);
SWAP_INT(swizzle[i][1], swizzle[i][2]);
}
#endif /* MESA_BIG_ENDIAN */
if (r300IsGartMemory(rmesa, VB->AttribPtr[tab[i]].data, /*(count-1)*stride */ 4)) {
#endif /* MESA_BIG_ENDIAN */
if (r300IsGartMemory(rmesa, VB->AttribPtr[tab[i]].data,
/*(count-1)*stride */ 4)) {
if (VB->AttribPtr[tab[i]].stride % 4)
return R300_FALLBACK_TCL;
rmesa->state.aos[i].address = VB->AttribPtr[tab[i]].data;
rmesa->state.aos[i].address =
VB->AttribPtr[tab[i]].data;
rmesa->state.aos[i].start = 0;
rmesa->state.aos[i].aos_offset = r300GartOffsetFromVirtual(rmesa, VB->AttribPtr[tab[i]].data);
rmesa->state.aos[i].aos_stride = VB->AttribPtr[tab[i]].stride / 4;
rmesa->state.aos[i].aos_size = t_emit_size(&VB->AttribPtr[tab[i]]);
rmesa->state.aos[i].aos_offset =
r300GartOffsetFromVirtual(rmesa,
VB->
AttribPtr[tab[i]].data);
rmesa->state.aos[i].aos_stride =
VB->AttribPtr[tab[i]].stride / 4;
rmesa->state.aos[i].aos_size =
t_emit_size(&VB->AttribPtr[tab[i]]);
} else {
/* TODO: emit_vector can only handle 4 byte vectors */
/* TODO: r300EmitVec can only handle 4 byte vectors */
if (VB->AttribPtr[tab[i]].type != GL_FLOAT)
return R300_FALLBACK_TCL;
emit_vector(ctx, &rmesa->state.aos[i], VB->AttribPtr[tab[i]].data,
t_emit_size(&VB->AttribPtr[tab[i]]), VB->AttribPtr[tab[i]].stride, count);
r300EmitVec(ctx, &rmesa->state.aos[i],
VB->AttribPtr[tab[i]].data,
t_emit_size(&VB->AttribPtr[tab[i]]),
VB->AttribPtr[tab[i]].stride, count);
}
rmesa->state.aos[i].aos_size = t_aos_size(&VB->AttribPtr[tab[i]]);
rmesa->state.aos[i].aos_size =
t_aos_size(&VB->AttribPtr[tab[i]]);
comp_size = _mesa_sizeof_type(VB->AttribPtr[tab[i]].type);
for (fix = 0; fix <= 4 - VB->AttribPtr[tab[i]].size; fix++) {
if ((rmesa->state.aos[i].aos_offset - comp_size * fix) % 4)
if ((rmesa->state.aos[i].aos_offset -
comp_size * fix) % 4)
continue;
found = 1;
break;
}
if (found) {
if (fix > 0) {
WARN_ONCE("Feeling lucky?\n");
}
rmesa->state.aos[i].aos_offset -= comp_size * fix;
for (ci = 0; ci < VB->AttribPtr[tab[i]].size; ci++)
swizzle[i][ci] += fix;
} else {
WARN_ONCE("Cannot handle offset %x with stride %d, comp %d\n",
rmesa->state.aos[i].aos_offset, rmesa->state.aos[i].aos_stride, VB->AttribPtr[tab[i]].size);
WARN_ONCE
("Cannot handle offset %x with stride %d, comp %d\n",
rmesa->state.aos[i].aos_offset,
rmesa->state.aos[i].aos_stride,
VB->AttribPtr[tab[i]].size);
return R300_FALLBACK_TCL;
}
}
/* setup INPUT_ROUTE */
R300_STATECHANGE(r300, vir[0]);
((drm_r300_cmd_header_t*)r300->hw.vir[0].cmd)->packet0.count =
t_vir0(&r300->hw.vir[0].cmd[R300_VIR_CNTL_0], VB->AttribPtr, inputs, tab, nr);
((drm_r300_cmd_header_t *) r300->hw.vir[0].cmd)->packet0.count =
t_vir0(&r300->hw.vir[0].cmd[R300_VIR_CNTL_0], VB->AttribPtr,
inputs, tab, nr);
R300_STATECHANGE(r300, vir[1]);
((drm_r300_cmd_header_t*)r300->hw.vir[1].cmd)->packet0.count =
t_vir1(&r300->hw.vir[1].cmd[R300_VIR_CNTL_0], swizzle, nr);
((drm_r300_cmd_header_t *) r300->hw.vir[1].cmd)->packet0.count =
t_vir1(&r300->hw.vir[1].cmd[R300_VIR_CNTL_0], swizzle, nr);
/* Set up input_cntl */
/* I don't think this is needed for vertex buffers, but it doesn't hurt anything */
R300_STATECHANGE(r300, vic);
r300->hw.vic.cmd[R300_VIC_CNTL_0] = 0x5555; /* Hard coded value, no idea what it means */
r300->hw.vic.cmd[R300_VIC_CNTL_0] = 0x5555; /* Hard coded value, no idea what it means */
r300->hw.vic.cmd[R300_VIC_CNTL_1] = t_vic(ctx, InputsRead);
/* Stage 3: VAP output */
R300_STATECHANGE(r300, vof);
r300->hw.vof.cmd[R300_VOF_CNTL_0]=0;
r300->hw.vof.cmd[R300_VOF_CNTL_1]=0;
r300->hw.vof.cmd[R300_VOF_CNTL_0] = 0;
r300->hw.vof.cmd[R300_VOF_CNTL_1] = 0;
if (OutputsWritten & (1 << VERT_RESULT_HPOS))
r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT;
r300->hw.vof.cmd[R300_VOF_CNTL_0] |=
R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT;
if (OutputsWritten & (1 << VERT_RESULT_COL0))
r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT;
r300->hw.vof.cmd[R300_VOF_CNTL_0] |=
R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT;
if (OutputsWritten & (1 << VERT_RESULT_COL1))
r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT;
r300->hw.vof.cmd[R300_VOF_CNTL_0] |=
R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT;
/*if(OutputsWritten & (1 << VERT_RESULT_BFC0))
r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT;
if(OutputsWritten & (1 << VERT_RESULT_BFC1))
r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT;*/
r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT;
if(OutputsWritten & (1 << VERT_RESULT_BFC1))
r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT; */
//if(OutputsWritten & (1 << VERT_RESULT_FOGC))
if (OutputsWritten & (1 << VERT_RESULT_PSIZ))
r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT;
r300->hw.vof.cmd[R300_VOF_CNTL_0] |=
R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT;
for(i=0;i < ctx->Const.MaxTextureUnits;i++)
if(OutputsWritten & (1 << (VERT_RESULT_TEX0 + i)))
for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
if (OutputsWritten & (1 << (VERT_RESULT_TEX0 + i)))
r300->hw.vof.cmd[R300_VOF_CNTL_1] |= (4 << (3 * i));
rmesa->state.aos_count = nr;
return R300_FALLBACK_NONE;
}
@@ -581,37 +604,14 @@ void r300UseArrays(GLcontext * ctx)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
int i;
if(rmesa->state.elt_dma.buf)
radeon_mm_use(rmesa, rmesa->state.elt_dma.buf->id);
for (i=0; i < rmesa->state.aos_count;i++) {
if (rmesa->state.elt_dma.buf)
r300_mem_use(rmesa, rmesa->state.elt_dma.buf->id);
for (i = 0; i < rmesa->state.aos_count; i++) {
if (rmesa->state.aos[i].buf)
radeon_mm_use(rmesa, rmesa->state.aos[i].buf->id);
r300_mem_use(rmesa, rmesa->state.aos[i].buf->id);
}
#ifdef HW_VBOS
#define USE_VBO(a) \
do { \
if (ctx->Array.ArrayObj->a.BufferObj->Name \
&& ctx->Array.ArrayObj->a.Enabled) \
radeon_mm_use(rmesa, ((struct r300_buffer_object *)ctx->Array.ArrayObj->a.BufferObj)->id); \
} while(0)
if (ctx->Array.ElementArrayBufferObj->Name && ctx->Array.ElementArrayBufferObj->OnCard)
radeon_mm_use(rmesa, ((struct r300_buffer_object *)ctx->Array.ElementArrayBufferObj)->id);
USE_VBO(Vertex);
USE_VBO(Normal);
USE_VBO(Color);
USE_VBO(SecondaryColor);
USE_VBO(FogCoord);
for (i=0; i < MAX_TEXTURE_COORD_UNITS; i++)
USE_VBO(TexCoord[i]);
#endif
}
#endif
@@ -621,7 +621,7 @@ void r300ReleaseArrays(GLcontext * ctx)
int i;
r300ReleaseDmaRegion(rmesa, &rmesa->state.elt_dma, __FUNCTION__);
for (i=0;i<rmesa->state.aos_count;i++) {
for (i = 0; i < rmesa->state.aos_count; i++) {
r300ReleaseDmaRegion(rmesa, &rmesa->state.aos[i], __FUNCTION__);
}
}

View File

@@ -59,10 +59,6 @@
#define CP_PACKET0(reg, n) (RADEON_CP_PACKET0 | ((n)<<16) | ((reg)>>2))
void static inline check_space(int dwords)
{
}
static __inline__ uint32_t cmdpacket0(int reg, int count)
{
drm_r300_cmd_header_t cmd;
@@ -138,7 +134,7 @@ static __inline__ uint32_t cmdpacify(void)
cmd = (drm_radeon_cmd_header_t*) \
r300AllocCmdBuf(rmesa, \
(_n+2), \
__func__); \
__FUNCTION__); \
cmd_reserved=_n+2; \
cmd_written=1; \
cmd[0].i=cmdpacket0((reg), _n+1); \
@@ -160,7 +156,7 @@ static __inline__ uint32_t cmdpacify(void)
"cmd_written=%d cmd_reserved=%d\n", \
__FILE__, __FUNCTION__, __LINE__, \
cmd_written, cmd_reserved); \
exit(-1); \
_mesa_exit(-1); \
} \
} while(0)
@@ -173,7 +169,7 @@ static __inline__ uint32_t cmdpacify(void)
cmd = (drm_radeon_cmd_header_t*) \
r300AllocCmdBuf(rmesa, \
(_n+1), \
__func__); \
__FUNCTION__); \
cmd_reserved = _n+2; \
cmd_written =1; \
cmd[0].i = cmdvpu((dest), _n/4); \
@@ -188,14 +184,14 @@ static __inline__ uint32_t cmdpacify(void)
cmd = (drm_radeon_cmd_header_t*) \
r300AllocCmdBuf(rmesa, \
(_n+3), \
__func__); \
__FUNCTION__); \
cmd_reserved = _n+3; \
cmd_written = 2; \
if(_n > 0x3fff) { \
fprintf(stderr,"Too big packet3 %08x: cannot " \
"store %d dwords\n", \
_p, _n); \
exit(-1); \
_mesa_exit(-1); \
} \
cmd[0].i = cmdpacket3(R300_CMD_PACKET3_RAW); \
cmd[1].i = _p | ((_n & 0x3fff)<<16); \
@@ -208,85 +204,35 @@ void static inline end_3d(r300ContextPtr rmesa)
{
drm_radeon_cmd_header_t *cmd = NULL;
cmd = (drm_radeon_cmd_header_t*)r300AllocCmdBuf(rmesa,
1,
__FUNCTION__);
cmd[0].header.cmd_type=R300_CMD_END3D;
cmd =
(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, 1, __FUNCTION__);
cmd[0].header.cmd_type = R300_CMD_END3D;
}
void static inline cp_delay(r300ContextPtr rmesa, unsigned short count)
{
drm_radeon_cmd_header_t *cmd = NULL;
cmd = (drm_radeon_cmd_header_t*)r300AllocCmdBuf(rmesa,
1,
__FUNCTION__);
cmd[0].i=cmdcpdelay(count);
cmd =
(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, 1, __FUNCTION__);
cmd[0].i = cmdcpdelay(count);
}
void static inline cp_wait(r300ContextPtr rmesa, unsigned char flags)
{
drm_radeon_cmd_header_t *cmd = NULL;
cmd = (drm_radeon_cmd_header_t*)r300AllocCmdBuf(rmesa,
1,
__FUNCTION__);
cmd =
(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, 1, __FUNCTION__);
cmd[0].i = cmdwait(flags);
}
/**
* fire vertex buffer
*/
static void inline fire_AOS(r300ContextPtr rmesa, int vertex_count, int type)
{
int cmd_reserved = 0;
int cmd_written = 0;
drm_radeon_cmd_header_t *cmd = NULL;
check_space(9);
extern int r300EmitArrays(GLcontext * ctx);
start_packet3(RADEON_CP_PACKET3_3D_DRAW_VBUF_2, 0);
#ifdef NOTNEEDED_ANYMORE
e32(0x840c0024);
#ifdef USER_BUFFERS
void r300UseArrays(GLcontext * ctx);
#endif
e32(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST |
(vertex_count<<16) | type);
}
/**
* These are followed by the corresponding data
*/
#define start_index32_packet(vertex_count, type) \
do { \
int _vc; \
_vc = (vertex_count); \
start_packet3(RADEON_CP_PACKET3_3D_DRAW_INDX_2, _vc); \
e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (_vc<<16) | \
type | R300_VAP_VF_CNTL__INDEX_SIZE_32bit); \
} while (0);
#define start_index16_packet(vertex_count, type) \
do { \
int _vc, _n; \
_vc = (vertex_count); \
_n = (vertex_count+1)>>1; \
start_packet3(RADEON_CP_PACKET3_3D_DRAW_INDX_2, _n); \
e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (_vc<<16) | \
type); \
} while (0);
/**
* Interestingly enough this ones needs the call to setup_AOS, even thought
* some of the data so setup is not needed and some is not as arbitrary
* as when used by DRAW_VBUF_2 or DRAW_INDX_2
*/
#define start_immediate_packet(vertex_count, type, vertex_size) \
do { \
int _vc; \
_vc = (vertex_count); \
start_packet3(RADEON_CP_PACKET3_3D_DRAW_IMMD_2, \
_vc*(vertex_size)); \
e32(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_EMBEDDED | \
(_vc<<16) | type); \
} while (0);
extern void r300ReleaseArrays(GLcontext * ctx);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -41,26 +41,6 @@
#include "r300_context.h"
#if 0
/* representation of a register for emit_arith/swizzle */
typedef struct _pfs_reg_t {
enum {
REG_TYPE_INPUT,
REG_TYPE_OUTPUT,
REG_TYPE_TEMP,
REG_TYPE_CONST
} type:2;
GLuint index:6;
GLuint v_swz:5;
GLuint s_swz:5;
GLuint negate_v:1;
GLuint negate_s:1;
GLuint absolute:1;
GLboolean no_use:1;
GLboolean valid:1;
} pfs_reg_t;
#endif
typedef struct r300_fragment_program_swizzle {
GLuint length;
GLuint src[4];
@@ -118,6 +98,7 @@ typedef struct r300_fragment_program_swizzle {
struct r300_fragment_program;
extern void r300_translate_fragment_shader(r300ContextPtr r300, struct r300_fragment_program *rp);
extern void r300TranslateFragmentShader(r300ContextPtr r300,
struct r300_fragment_program *fp);
#endif

View File

@@ -29,10 +29,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
/*
* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
* Nicolai Haehnle <prefect_@gmx.net>
/**
* \file
*
* \author Keith Whitwell <keith@tungstengraphics.com>
*
* \author Nicolai Haehnle <prefect_@gmx.net>
*/
#include <sched.h>
@@ -61,14 +63,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
{
GLcontext* ctx = r300->radeon.glCtx;
GLcontext *ctx = r300->radeon.glCtx;
__DRIdrawablePrivate *dPriv = r300->radeon.dri.drawable;
GLuint cboffset, cbpitch;
drm_r300_cmd_header_t* cmd2;
drm_r300_cmd_header_t *cmd2;
int cmd_reserved = 0;
int cmd_written = 0;
drm_radeon_cmd_header_t *cmd = NULL;
r300ContextPtr rmesa=r300;
r300ContextPtr rmesa = r300;
if (RADEON_DEBUG & DEBUG_IOCTL)
fprintf(stderr, "%s: %s buffer (%i,%i %ix%i)\n",
@@ -87,69 +89,78 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
cp_wait(r300, R300_WAIT_3D | R300_WAIT_3D_CLEAN);
end_3d(rmesa);
R300_STATECHANGE(r300, cb);
reg_start(R300_RB3D_COLOROFFSET0, 0);
e32(cboffset);
if (r300->radeon.radeonScreen->cpp == 4)
cbpitch |= R300_COLOR_FORMAT_ARGB8888;
else
cbpitch |= R300_COLOR_FORMAT_RGB565;
if (r300->radeon.sarea->tiling_enabled)
cbpitch |= R300_COLOR_TILE_ENABLE;
reg_start(R300_RB3D_COLORPITCH0, 0);
e32(cbpitch);
R300_STATECHANGE(r300, cmk);
reg_start(R300_RB3D_COLORMASK, 0);
if (flags & CLEARBUFFER_COLOR) {
e32((ctx->Color.ColorMask[BCOMP] ? R300_COLORMASK0_B : 0) |
(ctx->Color.ColorMask[GCOMP] ? R300_COLORMASK0_G : 0) |
(ctx->Color.ColorMask[RCOMP] ? R300_COLORMASK0_R : 0) |
(ctx->Color.ColorMask[ACOMP] ? R300_COLORMASK0_A : 0));
(ctx->Color.ColorMask[GCOMP] ? R300_COLORMASK0_G : 0) |
(ctx->Color.ColorMask[RCOMP] ? R300_COLORMASK0_R : 0) |
(ctx->Color.ColorMask[ACOMP] ? R300_COLORMASK0_A : 0));
} else {
e32(0);
e32(0x0);
}
R300_STATECHANGE(r300, zs);
reg_start(R300_RB3D_ZSTENCIL_CNTL_0, 2);
{
uint32_t t1, t2;
t1 = 0x0;
t2 = 0x0;
if (flags & CLEARBUFFER_DEPTH) {
t1 |= R300_RB3D_Z_WRITE_ONLY;
t2 |= (R300_ZS_ALWAYS << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT);
} else {
t1 |= R300_RB3D_Z_DISABLED_1; // disable
uint32_t t1, t2;
t1 = 0x0;
t2 = 0x0;
if (flags & CLEARBUFFER_DEPTH) {
t1 |= R300_RB3D_Z_WRITE_ONLY;
t2 |=
(R300_ZS_ALWAYS << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT);
} else {
t1 |= R300_RB3D_Z_DISABLED_1; // disable
}
if (flags & CLEARBUFFER_STENCIL) {
t1 |= R300_RB3D_STENCIL_ENABLE;
t2 |=
(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);
}
e32(t1);
e32(t2);
e32(r300->state.stencil.clear);
}
if (flags & CLEARBUFFER_STENCIL) {
t1 |= R300_RB3D_STENCIL_ENABLE;
t2 |=
(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) ;
}
e32(t1);
e32(t2);
e32(r300->state.stencil.clear);
}
cmd2 = (drm_r300_cmd_header_t*)r300AllocCmdBuf(r300, 9, __FUNCTION__);
cmd2 = (drm_r300_cmd_header_t *) r300AllocCmdBuf(r300, 9, __FUNCTION__);
cmd2[0].packet3.cmd_type = R300_CMD_PACKET3;
cmd2[0].packet3.packet = R300_CMD_PACKET3_CLEAR;
cmd2[1].u = r300PackFloat32(dPriv->w / 2.0);
@@ -161,11 +172,10 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
cmd2[7].u = r300PackFloat32(ctx->Color.ClearColor[2]);
cmd2[8].u = r300PackFloat32(ctx->Color.ClearColor[3]);
reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
reg_start(R300_RB3D_DSTCACHE_CTLSTAT, 0);
e32(R300_RB3D_DSTCACHE_UNKNOWN_0A);
reg_start(R300_RB3D_ZCACHE_CTLSTAT,0);
reg_start(R300_RB3D_ZCACHE_CTLSTAT, 0);
e32(R300_RB3D_ZCACHE_UNKNOWN_03);
cp_wait(rmesa, R300_WAIT_3D | R300_WAIT_3D_CLEAN);
}
@@ -173,7 +183,7 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
static void r300EmitClearState(GLcontext * ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
r300ContextPtr rmesa=r300;
r300ContextPtr rmesa = r300;
__DRIdrawablePrivate *dPriv = r300->radeon.dri.drawable;
int i;
int cmd_reserved = 0;
@@ -182,49 +192,62 @@ static void r300EmitClearState(GLcontext * ctx)
int has_tcl = 1;
if (!(r300->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL))
has_tcl = 0;
has_tcl = 0;
/* FIXME: the values written to R300_VAP_INPUT_ROUTE_0_0 and
* R300_VAP_INPUT_ROUTE_0_1 are in fact known, however, the values are
* quite complex; see the functions in r300_emit.c.
*
* I believe it would be a good idea to extend the functions in
* r300_emit.c so that they can be used to setup the default values for
* these registers, as well as the actual values used for rendering.
*/
R300_STATECHANGE(r300, vir[0]);
reg_start(R300_VAP_INPUT_ROUTE_0_0, 0);
if (!has_tcl)
e32(0x22030003);
e32(0x22030003);
else
e32(0x21030003);
e32(0x21030003);
/* disable fog */
R300_STATECHANGE(r300, fogs);
reg_start(R300_RE_FOG_STATE, 0);
e32(0x0);
R300_STATECHANGE(r300, vir[1]);
reg_start(R300_VAP_INPUT_ROUTE_1_0, 0);
e32(0xF688F688);
/* R300_VAP_INPUT_CNTL_0, R300_VAP_INPUT_CNTL_1 */
R300_STATECHANGE(r300, vic);
reg_start(R300_VAP_INPUT_CNTL_0, 1);
e32(0x00000001);
e32(0x00000405);
e32(R300_INPUT_CNTL_0_COLOR);
e32(R300_INPUT_CNTL_POS | R300_INPUT_CNTL_COLOR | R300_INPUT_CNTL_TC0);
if (!has_tcl) {
/* comes from fglrx startup of clear */
reg_start(R300_SE_VTE_CNTL, 1);
e32(0x043f);
e32(0x8);
reg_start(0x21dc, 0);
e32(0xaaaaaaaa);
R300_STATECHANGE(r300, vte);
/* comes from fglrx startup of clear */
reg_start(R300_SE_VTE_CNTL, 1);
e32(R300_VTX_W0_FMT | R300_VPORT_X_SCALE_ENA |
R300_VPORT_X_OFFSET_ENA | R300_VPORT_Y_SCALE_ENA |
R300_VPORT_Y_OFFSET_ENA | R300_VPORT_Z_SCALE_ENA |
R300_VPORT_Z_OFFSET_ENA);
e32(0x8);
reg_start(0x21dc, 0);
e32(0xaaaaaaaa);
}
R300_STATECHANGE(r300, vof);
reg_start(R300_VAP_OUTPUT_VTX_FMT_0, 1);
e32(R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT | R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT);
e32(0); /* no textures */
e32(R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT |
R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT);
e32(0x0); /* no textures */
R300_STATECHANGE(r300, txe);
reg_start(R300_TX_ENABLE, 0);
e32(0);
e32(0x0);
R300_STATECHANGE(r300, vpt);
reg_start(R300_SE_VPORT_XSCALE, 5);
efloat(1.0);
@@ -233,28 +256,28 @@ static void r300EmitClearState(GLcontext * ctx)
efloat(dPriv->y);
efloat(1.0);
efloat(0.0);
R300_STATECHANGE(r300, at);
reg_start(R300_PP_ALPHA_TEST, 0);
e32(0);
e32(0x0);
R300_STATECHANGE(r300, bld);
reg_start(R300_RB3D_CBLEND, 1);
e32(0);
e32(0);
e32(0x0);
e32(0x0);
R300_STATECHANGE(r300, unk221C);
reg_start(R300_VAP_UNKNOWN_221C, 0);
e32(R300_221C_CLEAR);
R300_STATECHANGE(r300, ps);
reg_start(R300_RE_POINTSIZE, 0);
e32(((dPriv->w * 6) << R300_POINTSIZE_X_SHIFT) |
((dPriv->h * 6) << R300_POINTSIZE_Y_SHIFT));
((dPriv->h * 6) << R300_POINTSIZE_Y_SHIFT));
R300_STATECHANGE(r300, ri);
reg_start(R300_RS_INTERP_0, 8);
for(i = 0; i < 8; ++i){
for (i = 0; i < 8; ++i) {
e32(R300_RS_INTERP_USED);
}
@@ -262,64 +285,61 @@ static void r300EmitClearState(GLcontext * ctx)
/* The second constant is needed to get glxgears display anything .. */
reg_start(R300_RS_CNTL_0, 1);
e32((1 << R300_RS_CNTL_CI_CNT_SHIFT) | R300_RS_CNTL_0_UNKNOWN_18);
e32(0);
e32(0x0);
R300_STATECHANGE(r300, rr);
reg_start(R300_RS_ROUTE_0, 0);
e32(0x00004000);
e32(R300_RS_ROUTE_0_COLOR);
R300_STATECHANGE(r300, fp);
reg_start(R300_PFS_CNTL_0, 2);
e32(0);
e32(0);
e32(0);
e32(0x0);
e32(0x0);
e32(0x0);
reg_start(R300_PFS_NODE_0, 3);
e32(0);
e32(0);
e32(0);
e32(0x0);
e32(0x0);
e32(0x0);
e32(R300_PFS_NODE_OUTPUT_COLOR);
R300_STATECHANGE(r300, fpi[0]);
R300_STATECHANGE(r300, fpi[1]);
R300_STATECHANGE(r300, fpi[2]);
R300_STATECHANGE(r300, fpi[3]);
reg_start(R300_PFS_INSTR0_0, 0);
e32(FP_INSTRC(MAD, FP_ARGC(SRC0C_XYZ), FP_ARGC(ONE), FP_ARGC(ZERO)));
reg_start(R300_PFS_INSTR1_0, 0);
e32(FP_SELC(0,NO,XYZ,FP_TMP(0),0,0));
e32(FP_SELC(0, NO, XYZ, FP_TMP(0), 0, 0));
reg_start(R300_PFS_INSTR2_0, 0);
e32(FP_INSTRA(MAD, FP_ARGA(SRC0A), FP_ARGA(ONE), FP_ARGA(ZERO)));
reg_start(R300_PFS_INSTR3_0, 0);
e32(FP_SELA(0,NO,W,FP_TMP(0),0,0));
e32(FP_SELA(0, NO, W, FP_TMP(0), 0, 0));
if (has_tcl) {
R300_STATECHANGE(r300, pvs);
reg_start(R300_VAP_PVS_CNTL_1, 2);
e32((0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) |
(0 << R300_PVS_CNTL_1_POS_END_SHIFT) |
(1 << R300_PVS_CNTL_1_PROGRAM_END_SHIFT));
e32(0);
e32(1 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT);
R300_STATECHANGE(r300, vpi);
vsf_start_fragment(0x0, 8);
e32(VP_OUT(ADD,OUT,0,XYZW));
e32(VP_IN(IN,0));
e32(VP_ZERO());
e32(0);
e32(VP_OUT(ADD,OUT,1,XYZW));
e32(VP_IN(IN,1));
e32(VP_ZERO());
e32(0);
R300_STATECHANGE(r300, pvs);
reg_start(R300_VAP_PVS_CNTL_1, 2);
e32((0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) |
(0 << R300_PVS_CNTL_1_POS_END_SHIFT) |
(1 << R300_PVS_CNTL_1_PROGRAM_END_SHIFT));
e32(0x0);
e32(1 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT);
R300_STATECHANGE(r300, vpi);
vsf_start_fragment(0x0, 8);
e32(VP_OUT(ADD, OUT, 0, XYZW));
e32(VP_IN(IN, 0));
e32(VP_ZERO());
e32(0x0);
e32(VP_OUT(ADD, OUT, 1, XYZW));
e32(VP_IN(IN, 1));
e32(VP_ZERO());
e32(0x0);
}
/*reg_start(0x4500,0);
e32(2560-1);*/
}
/**
@@ -357,8 +377,8 @@ static void r300Clear(GLcontext * ctx, GLbitfield mask)
bits |= CLEARBUFFER_DEPTH;
mask &= ~BUFFER_BIT_DEPTH;
}
if ( (mask & BUFFER_BIT_STENCIL) && r300->state.stencil.hw_stencil) {
if ((mask & BUFFER_BIT_STENCIL) && r300->state.stencil.hw_stencil) {
bits |= CLEARBUFFER_STENCIL;
mask &= ~BUFFER_BIT_STENCIL;
}
@@ -370,11 +390,11 @@ static void r300Clear(GLcontext * ctx, GLbitfield mask)
_swrast_Clear(ctx, mask);
}
swapped = r300->radeon.doPageFlip && (r300->radeon.sarea->pfCurrentPage == 1);
swapped = r300->radeon.sarea->pfCurrentPage == 1;
/* Make sure it fits there. */
r300EnsureCmdBufSpace(r300, 421*3, __FUNCTION__);
if(flags || bits)
r300EnsureCmdBufSpace(r300, 421 * 3, __FUNCTION__);
if (flags || bits)
r300EmitClearState(ctx);
if (flags & BUFFER_BIT_FRONT_LEFT) {
@@ -392,7 +412,6 @@ static void r300Clear(GLcontext * ctx, GLbitfield mask)
}
void r300Flush(GLcontext * ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
@@ -405,13 +424,13 @@ void r300Flush(GLcontext * ctx)
}
#ifdef USER_BUFFERS
#include "radeon_mm.h"
#include "r300_mem.h"
static void r300RefillCurrentDmaRegion(r300ContextPtr rmesa, int size)
{
struct r300_dma_buffer *dmabuf;
size = MAX2(size, RADEON_BUFFER_SIZE*16);
size = MAX2(size, RADEON_BUFFER_SIZE * 16);
if (RADEON_DEBUG & (DEBUG_IOCTL | DEBUG_DMA))
fprintf(stderr, "%s\n", __FUNCTION__);
@@ -424,37 +443,31 @@ static void r300RefillCurrentDmaRegion(r300ContextPtr rmesa, int size)
if (rmesa->dma.nr_released_bufs > 4)
r300FlushCmdBuf(rmesa, __FUNCTION__);
dmabuf = CALLOC_STRUCT(r300_dma_buffer);
dmabuf->buf = (void *)1; /* hack */
dmabuf->buf = (void *)1; /* hack */
dmabuf->refcount = 1;
dmabuf->id = radeon_mm_alloc(rmesa, 4, size);
dmabuf->id = r300_mem_alloc(rmesa, 4, size);
if (dmabuf->id == 0) {
LOCK_HARDWARE(&rmesa->radeon); /* no need to validate */
r300FlushCmdBufLocked(rmesa, __FUNCTION__);
radeonWaitForIdleLocked(&rmesa->radeon);
dmabuf->id = radeon_mm_alloc(rmesa, 4, size);
#ifdef HW_VBOS
if (dmabuf->id == 0) {
/* Just kick all */
r300_evict_vbos(rmesa->radeon.glCtx, /*RADEON_BUFFER_SIZE*16*/1<<30);
dmabuf->id = radeon_mm_alloc(rmesa, 4, size);
}
#endif
dmabuf->id = r300_mem_alloc(rmesa, 4, size);
UNLOCK_HARDWARE(&rmesa->radeon);
if (dmabuf->id == 0) {
fprintf(stderr, "Error: Could not get dma buffer... exiting\n");
exit(-1);
fprintf(stderr,
"Error: Could not get dma buffer... exiting\n");
_mesa_exit(-1);
}
}
rmesa->dma.current.buf = dmabuf;
rmesa->dma.current.address = radeon_mm_ptr(rmesa, dmabuf->id);
rmesa->dma.current.address = r300_mem_ptr(rmesa, dmabuf->id);
rmesa->dma.current.end = size;
rmesa->dma.current.start = 0;
rmesa->dma.current.ptr = 0;
@@ -473,7 +486,7 @@ void r300ReleaseDmaRegion(r300ContextPtr rmesa,
rmesa->dma.flush(rmesa);
if (--region->buf->refcount == 0) {
radeon_mm_free(rmesa, region->buf->id);
r300_mem_free(rmesa, region->buf->id);
FREE(region->buf);
rmesa->dma.nr_released_bufs++;
}
@@ -503,8 +516,7 @@ void r300AllocDmaRegion(r300ContextPtr rmesa,
(rmesa->dma.current.ptr + alignment) & ~alignment;
if (rmesa->dma.current.ptr + bytes > rmesa->dma.current.end)
r300RefillCurrentDmaRegion(rmesa,
(bytes + 0x7) & ~0x7);
r300RefillCurrentDmaRegion(rmesa, (bytes + 0x7) & ~0x7);
region->start = rmesa->dma.current.start;
region->ptr = rmesa->dma.current.start;
@@ -529,7 +541,7 @@ static void r300RefillCurrentDmaRegion(r300ContextPtr rmesa)
int size = 0;
drmDMAReq dma;
int ret;
if (RADEON_DEBUG & (DEBUG_IOCTL | DEBUG_DMA))
fprintf(stderr, "%s\n", __FUNCTION__);
@@ -572,8 +584,9 @@ static void r300RefillCurrentDmaRegion(r300ContextPtr rmesa)
if (ret != 0) {
UNLOCK_HARDWARE(&rmesa->radeon);
fprintf(stderr, "Error: Could not get dma buffer... exiting\n");
exit(-1);
fprintf(stderr,
"Error: Could not get dma buffer... exiting\n");
_mesa_exit(-1);
}
}
@@ -609,15 +622,16 @@ void r300ReleaseDmaRegion(r300ContextPtr rmesa,
drm_radeon_cmd_header_t *cmd;
if (RADEON_DEBUG & (DEBUG_IOCTL | DEBUG_DMA))
fprintf(stderr, "%s -- DISCARD BUF %d\n", __FUNCTION__,
region->buf->buf->idx);
fprintf(stderr, "%s -- DISCARD BUF %d\n",
__FUNCTION__, region->buf->buf->idx);
cmd =
(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa,
sizeof(*cmd) / 4,
sizeof
(*cmd) / 4,
__FUNCTION__);
cmd->dma.cmd_type = R300_CMD_DMA_DISCARD;
cmd->dma.buf_idx = region->buf->buf->idx;
FREE(region->buf);
rmesa->dma.nr_released_bufs++;
}
@@ -665,34 +679,15 @@ void r300AllocDmaRegion(r300ContextPtr rmesa,
#endif
/* Called via glXGetMemoryOffsetMESA() */
GLuint r300GetMemoryOffsetMESA(__DRInativeDisplay * dpy, int scrn,
const GLvoid * pointer)
{
GET_CURRENT_CONTEXT(ctx);
r300ContextPtr rmesa;
GLuint card_offset;
if (!ctx || !(rmesa = R300_CONTEXT(ctx))) {
fprintf(stderr, "%s: no context\n", __FUNCTION__);
return ~0;
}
if (!r300IsGartMemory(rmesa, pointer, 0))
return ~0;
card_offset = r300GartOffsetFromVirtual(rmesa, pointer);
return card_offset - rmesa->radeon.radeonScreen->gart_base;
}
GLboolean r300IsGartMemory(r300ContextPtr rmesa, const GLvoid * pointer,
GLint size)
{
int offset =
(char *)pointer - (char *)rmesa->radeon.radeonScreen->gartTextures.map;
(char *)pointer -
(char *)rmesa->radeon.radeonScreen->gartTextures.map;
int valid = (size >= 0 && offset >= 0
&& offset + size < rmesa->radeon.radeonScreen->gartTextures.size);
&& offset + size <
rmesa->radeon.radeonScreen->gartTextures.size);
if (RADEON_DEBUG & DEBUG_IOCTL)
fprintf(stderr, "r300IsGartMemory( %p ) : %d\n", pointer,
@@ -704,11 +699,13 @@ GLboolean r300IsGartMemory(r300ContextPtr rmesa, const GLvoid * pointer,
GLuint r300GartOffsetFromVirtual(r300ContextPtr rmesa, const GLvoid * pointer)
{
int offset =
(char *)pointer - (char *)rmesa->radeon.radeonScreen->gartTextures.map;
(char *)pointer -
(char *)rmesa->radeon.radeonScreen->gartTextures.map;
//fprintf(stderr, "offset=%08x\n", offset);
if (offset < 0 || offset > rmesa->radeon.radeonScreen->gartTextures.size)
if (offset < 0
|| offset > rmesa->radeon.radeonScreen->gartTextures.size)
return ~0;
else
return rmesa->radeon.radeonScreen->gart_texture_offset + offset;

View File

@@ -39,11 +39,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r300_context.h"
#include "radeon_drm.h"
extern GLuint r300GetMemoryOffsetMESA(__DRInativeDisplay * dpy, int scrn,
const GLvoid * pointer);
extern GLboolean r300IsGartMemory(r300ContextPtr rmesa, const GLvoid * pointer,
GLint size);
extern GLboolean r300IsGartMemory(r300ContextPtr rmesa,
const GLvoid * pointer, GLint size);
extern GLuint r300GartOffsetFromVirtual(r300ContextPtr rmesa,
const GLvoid * pointer);
@@ -51,10 +48,11 @@ extern GLuint r300GartOffsetFromVirtual(r300ContextPtr rmesa,
extern void r300Flush(GLcontext * ctx);
extern void r300ReleaseDmaRegion(r300ContextPtr rmesa,
struct r300_dma_region *region, const char *caller);
struct r300_dma_region *region,
const char *caller);
extern void r300AllocDmaRegion(r300ContextPtr rmesa,
struct r300_dma_region *region,
int bytes, int alignment);
struct r300_dma_region *region, int bytes,
int alignment);
extern void r300InitIoctlFuncs(struct dd_function_table *functions);

View File

@@ -1,53 +0,0 @@
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
initial release of the Radeon 8500 driver under the XFree86 license.
This notice must be preserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice (including the
next paragraph) shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
/*
* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
*/
#ifndef __R300_MAOS_H__
#define __R300_MAOS_H__
#ifdef GLX_DIRECT_RENDERING
#include "r300_context.h"
extern void r300EmitElts(GLcontext * ctx, void *elts, unsigned long n_elts, int elt_size);
extern int r300EmitArrays(GLcontext *ctx);
#ifdef USER_BUFFERS
void r300UseArrays(GLcontext * ctx);
#endif
extern void r300ReleaseArrays(GLcontext * ctx);
#endif
#endif

View File

@@ -0,0 +1,385 @@
/*
* Copyright (C) 2005 Aapo Tahkola.
*
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
/**
* \file
*
* \author Aapo Tahkola <aet@rasterburn.org>
*/
#include <unistd.h>
#include "r300_context.h"
#include "r300_cmdbuf.h"
#include "r300_ioctl.h"
#include "r300_mem.h"
#include "radeon_ioctl.h"
#ifdef USER_BUFFERS
static void resize_u_list(r300ContextPtr rmesa)
{
void *temp;
int nsize;
temp = rmesa->rmm->u_list;
nsize = rmesa->rmm->u_size * 2;
rmesa->rmm->u_list = _mesa_malloc(nsize * sizeof(*rmesa->rmm->u_list));
_mesa_memset(rmesa->rmm->u_list, 0,
nsize * sizeof(*rmesa->rmm->u_list));
if (temp) {
r300FlushCmdBuf(rmesa, __FUNCTION__);
_mesa_memcpy(rmesa->rmm->u_list, temp,
rmesa->rmm->u_size * sizeof(*rmesa->rmm->u_list));
_mesa_free(temp);
}
rmesa->rmm->u_size = nsize;
}
void r300_mem_init(r300ContextPtr rmesa)
{
rmesa->rmm = malloc(sizeof(struct r300_memory_manager));
memset(rmesa->rmm, 0, sizeof(struct r300_memory_manager));
rmesa->rmm->u_size = 128;
resize_u_list(rmesa);
}
void r300_mem_destroy(r300ContextPtr rmesa)
{
_mesa_free(rmesa->rmm->u_list);
rmesa->rmm->u_list = NULL;
_mesa_free(rmesa->rmm);
rmesa->rmm = NULL;
}
void *r300_mem_ptr(r300ContextPtr rmesa, int id)
{
assert(id <= rmesa->rmm->u_last);
return rmesa->rmm->u_list[id].ptr;
}
int r300_mem_find(r300ContextPtr rmesa, void *ptr)
{
int i;
for (i = 1; i < rmesa->rmm->u_size + 1; i++)
if (rmesa->rmm->u_list[i].ptr &&
ptr >= rmesa->rmm->u_list[i].ptr &&
ptr <
rmesa->rmm->u_list[i].ptr + rmesa->rmm->u_list[i].size)
break;
if (i < rmesa->rmm->u_size + 1)
return i;
fprintf(stderr, "%p failed\n", ptr);
return 0;
}
//#define MM_DEBUG
int r300_mem_alloc(r300ContextPtr rmesa, int alignment, int size)
{
drm_radeon_mem_alloc_t alloc;
int offset = 0, ret;
int i, free = -1;
int done_age;
drm_radeon_mem_free_t memfree;
int tries = 0;
static int bytes_wasted = 0, allocated = 0;
if (size < 4096)
bytes_wasted += 4096 - size;
allocated += size;
#if 0
static int t = 0;
if (t != time(NULL)) {
t = time(NULL);
fprintf(stderr, "slots used %d, wasted %d kb, allocated %d\n",
rmesa->rmm->u_last, bytes_wasted / 1024,
allocated / 1024);
}
#endif
memfree.region = RADEON_MEM_REGION_GART;
again:
done_age = radeonGetAge((radeonContextPtr) rmesa);
if (rmesa->rmm->u_last + 1 >= rmesa->rmm->u_size)
resize_u_list(rmesa);
for (i = rmesa->rmm->u_last + 1; i > 0; i--) {
if (rmesa->rmm->u_list[i].ptr == NULL) {
free = i;
continue;
}
if (rmesa->rmm->u_list[i].h_pending == 0 &&
rmesa->rmm->u_list[i].pending
&& rmesa->rmm->u_list[i].age <= done_age) {
memfree.region_offset =
(char *)rmesa->rmm->u_list[i].ptr -
(char *)rmesa->radeon.radeonScreen->gartTextures.
map;
ret =
drmCommandWrite(rmesa->radeon.radeonScreen->
driScreen->fd, DRM_RADEON_FREE,
&memfree, sizeof(memfree));
if (ret) {
fprintf(stderr, "Failed to free at %p\n",
rmesa->rmm->u_list[i].ptr);
fprintf(stderr, "ret = %s\n", strerror(-ret));
exit(1);
} else {
#ifdef MM_DEBUG
fprintf(stderr, "really freed %d at age %x\n",
i,
radeonGetAge((radeonContextPtr) rmesa));
#endif
if (i == rmesa->rmm->u_last)
rmesa->rmm->u_last--;
if (rmesa->rmm->u_list[i].size < 4096)
bytes_wasted -=
4096 - rmesa->rmm->u_list[i].size;
allocated -= rmesa->rmm->u_list[i].size;
rmesa->rmm->u_list[i].pending = 0;
rmesa->rmm->u_list[i].ptr = NULL;
free = i;
}
}
}
rmesa->rmm->u_head = i;
if (free == -1) {
WARN_ONCE("Ran out of slots!\n");
//usleep(100);
r300FlushCmdBuf(rmesa, __FUNCTION__);
tries++;
if (tries > 100) {
WARN_ONCE("Ran out of slots!\n");
exit(1);
}
goto again;
}
alloc.region = RADEON_MEM_REGION_GART;
alloc.alignment = alignment;
alloc.size = size;
alloc.region_offset = &offset;
ret =
drmCommandWriteRead(rmesa->radeon.dri.fd, DRM_RADEON_ALLOC, &alloc,
sizeof(alloc));
if (ret) {
#if 0
WARN_ONCE("Ran out of mem!\n");
r300FlushCmdBuf(rmesa, __FUNCTION__);
//usleep(100);
tries2++;
tries = 0;
if (tries2 > 100) {
WARN_ONCE("Ran out of GART memory!\n");
exit(1);
}
goto again;
#else
WARN_ONCE
("Ran out of GART memory (for %d)!\nPlease consider adjusting GARTSize option.\n",
size);
return 0;
#endif
}
i = free;
if (i > rmesa->rmm->u_last)
rmesa->rmm->u_last = i;
rmesa->rmm->u_list[i].ptr =
((GLubyte *) rmesa->radeon.radeonScreen->gartTextures.map) + offset;
rmesa->rmm->u_list[i].size = size;
rmesa->rmm->u_list[i].age = 0;
//fprintf(stderr, "alloc %p at id %d\n", rmesa->rmm->u_list[i].ptr, i);
#ifdef MM_DEBUG
fprintf(stderr, "allocated %d at age %x\n", i,
radeonGetAge((radeonContextPtr) rmesa));
#endif
return i;
}
void r300_mem_use(r300ContextPtr rmesa, int id)
{
uint64_t ull;
#ifdef MM_DEBUG
fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id,
radeonGetAge((radeonContextPtr) rmesa));
#endif
drm_r300_cmd_header_t *cmd;
assert(id <= rmesa->rmm->u_last);
if (id == 0)
return;
cmd =
(drm_r300_cmd_header_t *) r300AllocCmdBuf(rmesa,
2 + sizeof(ull) / 4,
__FUNCTION__);
cmd[0].scratch.cmd_type = R300_CMD_SCRATCH;
cmd[0].scratch.reg = R300_MEM_SCRATCH;
cmd[0].scratch.n_bufs = 1;
cmd[0].scratch.flags = 0;
cmd++;
ull = (uint64_t) (intptr_t) & rmesa->rmm->u_list[id].age;
_mesa_memcpy(cmd, &ull, sizeof(ull));
cmd += sizeof(ull) / 4;
cmd[0].u = /*id */ 0;
LOCK_HARDWARE(&rmesa->radeon); /* Protect from DRM. */
rmesa->rmm->u_list[id].h_pending++;
UNLOCK_HARDWARE(&rmesa->radeon);
}
unsigned long r300_mem_offset(r300ContextPtr rmesa, int id)
{
unsigned long offset;
assert(id <= rmesa->rmm->u_last);
offset = (char *)rmesa->rmm->u_list[id].ptr -
(char *)rmesa->radeon.radeonScreen->gartTextures.map;
offset += rmesa->radeon.radeonScreen->gart_texture_offset;
return offset;
}
void *r300_mem_map(r300ContextPtr rmesa, int id, int access)
{
#ifdef MM_DEBUG
fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id,
radeonGetAge((radeonContextPtr) rmesa));
#endif
void *ptr;
int tries = 0;
assert(id <= rmesa->rmm->u_last);
if (access == R300_MEM_R) {
if (rmesa->rmm->u_list[id].mapped == 1)
WARN_ONCE("buffer %d already mapped\n", id);
rmesa->rmm->u_list[id].mapped = 1;
ptr = r300_mem_ptr(rmesa, id);
return ptr;
}
if (rmesa->rmm->u_list[id].h_pending)
r300FlushCmdBuf(rmesa, __FUNCTION__);
if (rmesa->rmm->u_list[id].h_pending) {
return NULL;
}
while (rmesa->rmm->u_list[id].age >
radeonGetAge((radeonContextPtr) rmesa) && tries++ < 1000)
usleep(10);
if (tries >= 1000) {
fprintf(stderr, "Idling failed (%x vs %x)\n",
rmesa->rmm->u_list[id].age,
radeonGetAge((radeonContextPtr) rmesa));
return NULL;
}
if (rmesa->rmm->u_list[id].mapped == 1)
WARN_ONCE("buffer %d already mapped\n", id);
rmesa->rmm->u_list[id].mapped = 1;
ptr = r300_mem_ptr(rmesa, id);
return ptr;
}
void r300_mem_unmap(r300ContextPtr rmesa, int id)
{
#ifdef MM_DEBUG
fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id,
radeonGetAge((radeonContextPtr) rmesa));
#endif
assert(id <= rmesa->rmm->u_last);
if (rmesa->rmm->u_list[id].mapped == 0)
WARN_ONCE("buffer %d not mapped\n", id);
rmesa->rmm->u_list[id].mapped = 0;
}
void r300_mem_free(r300ContextPtr rmesa, int id)
{
#ifdef MM_DEBUG
fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id,
radeonGetAge((radeonContextPtr) rmesa));
#endif
assert(id <= rmesa->rmm->u_last);
if (id == 0)
return;
if (rmesa->rmm->u_list[id].ptr == NULL) {
WARN_ONCE("Not allocated!\n");
return;
}
if (rmesa->rmm->u_list[id].pending) {
WARN_ONCE("%p already pended!\n", rmesa->rmm->u_list[id].ptr);
return;
}
rmesa->rmm->u_list[id].pending = 1;
}
#endif

View File

@@ -0,0 +1,37 @@
#ifndef __R300_MEM_H__
#define __R300_MEM_H__
//#define R300_MEM_PDL 0
#define R300_MEM_UL 1
#define R300_MEM_R 1
#define R300_MEM_W 2
#define R300_MEM_RW (R300_MEM_R | R300_MEM_W)
#define R300_MEM_SCRATCH 2
struct r300_memory_manager {
struct {
void *ptr;
uint32_t size;
uint32_t age;
uint32_t h_pending;
int pending;
int mapped;
} *u_list;
int u_head, u_size, u_last;
};
extern void r300_mem_init(r300ContextPtr rmesa);
extern void r300_mem_destroy(r300ContextPtr rmesa);
extern void *r300_mem_ptr(r300ContextPtr rmesa, int id);
extern int r300_mem_find(r300ContextPtr rmesa, void *ptr);
extern int r300_mem_alloc(r300ContextPtr rmesa, int alignment, int size);
extern void r300_mem_use(r300ContextPtr rmesa, int id);
extern unsigned long r300_mem_offset(r300ContextPtr rmesa, int id);
extern void *r300_mem_map(r300ContextPtr rmesa, int id, int access);
extern void r300_mem_unmap(r300ContextPtr rmesa, int id);
extern void r300_mem_free(r300ContextPtr rmesa, int id);
#endif

View File

@@ -145,6 +145,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
((arg1) << R300_FPI2_ARG1A_SHIFT) | \
((arg2) << R300_FPI2_ARG2A_SHIFT))
extern void debug_vp(GLcontext *ctx, struct gl_vertex_program *vp);
#endif /* __R300_PROGRAM_H__ */
extern void debug_vp(GLcontext * ctx, struct gl_vertex_program *vp);
#endif /* __R300_PROGRAM_H__ */

View File

@@ -23,6 +23,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
/* *INDENT-OFF* */
#ifndef _R300_REG_H
#define _R300_REG_H
@@ -488,6 +490,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_GB_W_SELECT_1 (1<<4)
#define R300_GB_AA_CONFIG 0x4020
# define R300_AA_DISABLE 0x00
# define R300_AA_ENABLE 0x01
# define R300_AA_SUBSAMPLES_2 0
# define R300_AA_SUBSAMPLES_3 (1<<1)
@@ -670,6 +673,11 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* Special handling for color: When the fragment program uses color,
* the ROUTE_0_COLOR bit is set and ROUTE_0_COLOR_DEST contains the
* color register index.
*
* Apperently you may set the R300_RS_ROUTE_0_COLOR bit, but not provide any
* R300_RS_ROUTE_0_COLOR_DEST value; this setup is used for clearing the state.
* See r300_ioctl.c:r300EmitClearState. I'm not sure if this setup is strictly
* correct or not. - Oliver.
*/
# define R300_RS_ROUTE_0_COLOR (1 << 14)
# define R300_RS_ROUTE_0_COLOR_DEST_SHIFT 17
@@ -1554,6 +1562,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define R300_PRIM_COLOR_ORDER_BGRA (0 << 6)
#define R300_PRIM_COLOR_ORDER_RGBA (1 << 6)
#define R300_PRIM_NUM_VERTICES_SHIFT 16
#define R300_PRIM_NUM_VERTICES_MASK 0xffff
/* Draw a primitive from vertex data in arrays loaded via 3D_LOAD_VBPNTR.
* Two parameter dwords:
@@ -1602,5 +1611,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define R300_CP_CMD_BITBLT_MULTI 0xC0009B00
#endif /* _R300_REG_H */
/* *INDENT-ON* */

View File

@@ -25,9 +25,26 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
/*
* Authors:
* Nicolai Haehnle <prefect_@gmx.net>
/**
* \file
*
* \brief R300 Render (Vertex Buffer Implementation)
*
* The immediate implementation has been removed from CVS in favor of the vertex
* buffer implementation.
*
* The render functions are called by the pipeline manager to render a batch of
* primitives. They return TRUE to pass on to the next stage (i.e. software
* rasterization) or FALSE to indicate that the pipeline has finished after
* rendering something.
*
* When falling back to software TCL still attempt to use hardware
* rasterization.
*
* I am not sure that the cache related registers are setup correctly, but
* obviously this does work... Further investigation is needed.
*
* \author Nicolai Haehnle <prefect_@gmx.net>
*/
#include "glheader.h"
@@ -38,14 +55,12 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#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 "vbo/vbo.h"
#include "tnl/tnl.h"
#include "tnl/t_vp_build.h"
#include "radeon_reg.h"
#include "radeon_macros.h"
#include "radeon_ioctl.h"
@@ -54,272 +69,311 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r300_ioctl.h"
#include "r300_state.h"
#include "r300_reg.h"
#include "r300_program.h"
#include "r300_tex.h"
#include "r300_maos.h"
#include "r300_emit.h"
extern int future_hw_tcl_on;
/**********************************************************************
* Hardware rasterization
*
* When we fell back to software TCL, we still try to use the
* rasterization hardware for rendering.
**********************************************************************/
static int r300_get_primitive_type(r300ContextPtr rmesa, GLcontext *ctx, int prim)
/**
* \brief Convert a OpenGL primitive type into a R300 primitive type.
*/
static int r300PrimitiveType(r300ContextPtr rmesa, GLcontext * ctx, int prim)
{
int type=-1;
switch (prim & PRIM_MODE_MASK) {
case GL_POINTS:
type=R300_VAP_VF_CNTL__PRIM_POINTS;
break;
case GL_LINES:
type=R300_VAP_VF_CNTL__PRIM_LINES;
break;
case GL_LINE_STRIP:
type=R300_VAP_VF_CNTL__PRIM_LINE_STRIP;
break;
case GL_LINE_LOOP:
type=R300_VAP_VF_CNTL__PRIM_LINE_LOOP;
break;
case GL_TRIANGLES:
type=R300_VAP_VF_CNTL__PRIM_TRIANGLES;
break;
case GL_TRIANGLE_STRIP:
type=R300_VAP_VF_CNTL__PRIM_TRIANGLE_STRIP;
break;
case GL_TRIANGLE_FAN:
type=R300_VAP_VF_CNTL__PRIM_TRIANGLE_FAN;
break;
case GL_QUADS:
type=R300_VAP_VF_CNTL__PRIM_QUADS;
break;
case GL_QUAD_STRIP:
type=R300_VAP_VF_CNTL__PRIM_QUAD_STRIP;
break;
case GL_POLYGON:
type=R300_VAP_VF_CNTL__PRIM_POLYGON;
return R300_VAP_VF_CNTL__PRIM_POINTS;
break;
default:
fprintf(stderr, "%s:%s Do not know how to handle primitive %02x - help me !\n",
__FILE__, __FUNCTION__,
prim & PRIM_MODE_MASK);
case GL_LINES:
return R300_VAP_VF_CNTL__PRIM_LINES;
break;
case GL_LINE_STRIP:
return R300_VAP_VF_CNTL__PRIM_LINE_STRIP;
break;
case GL_LINE_LOOP:
return R300_VAP_VF_CNTL__PRIM_LINE_LOOP;
break;
case GL_TRIANGLES:
return R300_VAP_VF_CNTL__PRIM_TRIANGLES;
break;
case GL_TRIANGLE_STRIP:
return R300_VAP_VF_CNTL__PRIM_TRIANGLE_STRIP;
break;
case GL_TRIANGLE_FAN:
return R300_VAP_VF_CNTL__PRIM_TRIANGLE_FAN;
break;
case GL_QUADS:
return R300_VAP_VF_CNTL__PRIM_QUADS;
break;
case GL_QUAD_STRIP:
return R300_VAP_VF_CNTL__PRIM_QUAD_STRIP;
break;
case GL_POLYGON:
return R300_VAP_VF_CNTL__PRIM_POLYGON;
break;
default:
assert(0);
return -1;
break;
}
return type;
break;
}
}
int r300_get_num_verts(r300ContextPtr rmesa, int num_verts, int prim)
static int r300NumVerts(r300ContextPtr rmesa, int num_verts, int prim)
{
int verts_off=0;
char *name="UNKNOWN";
int verts_off = 0;
switch (prim & PRIM_MODE_MASK) {
case GL_POINTS:
name="P";
verts_off = 0;
break;
break;
case GL_LINES:
name="L";
verts_off = num_verts % 2;
break;
break;
case GL_LINE_STRIP:
name="LS";
if(num_verts < 2)
if (num_verts < 2)
verts_off = num_verts;
break;
break;
case GL_LINE_LOOP:
name="LL";
if(num_verts < 2)
if (num_verts < 2)
verts_off = num_verts;
break;
case GL_TRIANGLES:
name="T";
break;
case GL_TRIANGLES:
verts_off = num_verts % 3;
break;
case GL_TRIANGLE_STRIP:
name="TS";
if(num_verts < 3)
break;
case GL_TRIANGLE_STRIP:
if (num_verts < 3)
verts_off = num_verts;
break;
case GL_TRIANGLE_FAN:
name="TF";
if(num_verts < 3)
break;
case GL_TRIANGLE_FAN:
if (num_verts < 3)
verts_off = num_verts;
break;
break;
case GL_QUADS:
name="Q";
verts_off = num_verts % 4;
break;
break;
case GL_QUAD_STRIP:
name="QS";
if(num_verts < 4)
if (num_verts < 4)
verts_off = num_verts;
else
verts_off = num_verts % 2;
break;
break;
case GL_POLYGON:
name="P";
if(num_verts < 3)
if (num_verts < 3)
verts_off = num_verts;
break;
default:
fprintf(stderr, "%s:%s Do not know how to handle primitive %02x - help me !\n",
__FILE__, __FUNCTION__,
prim & PRIM_MODE_MASK);
default:
assert(0);
return -1;
break;
}
if (RADEON_DEBUG & DEBUG_VERTS) {
if (num_verts - verts_off == 0) {
WARN_ONCE("user error: Need more than %d vertices to draw primitive %s !\n", num_verts, name);
return 0;
}
if (verts_off > 0) {
WARN_ONCE("user error: %d is not a valid number of vertices for primitive %s !\n", num_verts, name);
}
break;
}
return num_verts - verts_off;
}
/* Immediate implementation has been removed from CVS. */
static void r300EmitElts(GLcontext * ctx, void *elts, unsigned long n_elts,
int elt_size)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct r300_dma_region *rvb = &rmesa->state.elt_dma;
void *out;
/* vertex buffer implementation */
assert(elt_size == 2 || elt_size == 4);
static void inline fire_EB(r300ContextPtr rmesa, unsigned long addr, int vertex_count, int type, int elt_size)
if (r300IsGartMemory(rmesa, elts, n_elts * elt_size)) {
rvb->address = rmesa->radeon.radeonScreen->gartTextures.map;
rvb->start = ((char *)elts) - rvb->address;
rvb->aos_offset =
rmesa->radeon.radeonScreen->gart_texture_offset +
rvb->start;
return;
} else if (r300IsGartMemory(rmesa, elts, 1)) {
WARN_ONCE("Pointer not within GART memory!\n");
_mesa_exit(-1);
}
r300AllocDmaRegion(rmesa, rvb, n_elts * elt_size, elt_size);
rvb->aos_offset = GET_START(rvb);
out = rvb->address + rvb->start;
memcpy(out, elts, n_elts * elt_size);
}
static void r300FireEB(r300ContextPtr rmesa, unsigned long addr,
int vertex_count, int type, int elt_size)
{
int cmd_reserved = 0;
int cmd_written = 0;
drm_radeon_cmd_header_t *cmd = NULL;
unsigned long addr_a;
unsigned long t_addr;
unsigned long magic_1, magic_2;
GLcontext *ctx;
ctx = rmesa->radeon.glCtx;
assert(elt_size == 2 || elt_size == 4);
if(addr & (elt_size-1)){
if (addr & (elt_size - 1)) {
WARN_ONCE("Badly aligned buffer\n");
return ;
return;
}
#ifdef OPTIMIZE_ELTS
addr_a = 0;
magic_1 = (addr % 32) / 4;
t_addr = addr & (~0x1d);
t_addr = addr & ~0x1d;
magic_2 = (vertex_count + 1 + (t_addr & 0x2)) / 2 + magic_1;
check_space(6);
start_packet3(RADEON_CP_PACKET3_3D_DRAW_INDX_2, 0);
if(elt_size == 4){
e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (vertex_count<<16) | type | R300_VAP_VF_CNTL__INDEX_SIZE_32bit);
if (elt_size == 4) {
e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES |
(vertex_count << 16) | type |
R300_VAP_VF_CNTL__INDEX_SIZE_32bit);
} else {
e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (vertex_count<<16) | type);
e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES |
(vertex_count << 16) | type);
}
start_packet3(RADEON_CP_PACKET3_INDX_BUFFER, 2);
if(elt_size == 4){
#ifdef OPTIMIZE_ELTS
if (elt_size == 4) {
e32(R300_EB_UNK1 | (0 << 16) | R300_EB_UNK2);
e32(addr /*& 0xffffffe3*/);
e32(addr);
} else {
e32(R300_EB_UNK1 | (magic_1 << 16) | R300_EB_UNK2);
e32(t_addr);
}
if(elt_size == 4){
e32(vertex_count /*+ addr_a/4*/); /* Total number of dwords needed? */
} else {
e32(magic_2); /* Total number of dwords needed? */
}
//cp_delay(rmesa, 1);
#if 0
fprintf(stderr, "magic_1 %d\n", magic_1);
fprintf(stderr, "t_addr %x\n", t_addr);
fprintf(stderr, "magic_2 %d\n", magic_2);
exit(1);
#endif
#else
(void)magic_2, (void)magic_1, (void)t_addr;
addr_a = 0;
check_space(6);
start_packet3(RADEON_CP_PACKET3_3D_DRAW_INDX_2, 0);
if(elt_size == 4){
e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (vertex_count<<16) | type | R300_VAP_VF_CNTL__INDEX_SIZE_32bit);
} else {
e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (vertex_count<<16) | type);
}
start_packet3(RADEON_CP_PACKET3_INDX_BUFFER, 2);
e32(R300_EB_UNK1 | (0 << 16) | R300_EB_UNK2);
e32(addr /*& 0xffffffe3*/);
if(elt_size == 4){
e32(vertex_count /*+ addr_a/4*/); /* Total number of dwords needed? */
} else {
e32((vertex_count+1)/2 /*+ addr_a/4*/); /* Total number of dwords needed? */
}
//cp_delay(rmesa, 1);
e32(addr);
#endif
if (elt_size == 4) {
e32(vertex_count);
} else {
#ifdef OPTIMIZE_ELTS
e32(magic_2);
#else
e32((vertex_count + 1) / 2);
#endif
}
}
static void r300_render_vb_primitive(r300ContextPtr rmesa,
GLcontext *ctx,
int start,
int end,
int prim)
static void r300EmitAOS(r300ContextPtr rmesa, GLuint nr, GLuint offset)
{
int type, num_verts;
type=r300_get_primitive_type(rmesa, ctx, prim);
num_verts=r300_get_num_verts(rmesa, end-start, prim);
if(type<0 || num_verts <= 0)return;
if(rmesa->state.VB.Elts){
r300EmitAOS(rmesa, rmesa->state.aos_count, /*0*/start);
#if 0
int sz = 1 + (nr >> 1) * 3 + (nr & 1) * 2;
int i;
int cmd_reserved = 0;
int cmd_written = 0;
drm_radeon_cmd_header_t *cmd = NULL;
int i;
start_index32_packet(num_verts, type);
for(i=0; i < num_verts; i++)
e32(((unsigned long *)rmesa->state.VB.Elts)[i]/*rmesa->state.Elts[start+i]*/); /* start ? */
#else
if(num_verts == 1){
//start_index32_packet(num_verts, type);
//e32(rmesa->state.Elts[start]);
return;
if (RADEON_DEBUG & DEBUG_VERTS)
fprintf(stderr, "%s: nr=%d, ofs=0x%08x\n", __FUNCTION__, nr,
offset);
start_packet3(RADEON_CP_PACKET3_3D_LOAD_VBPNTR, sz - 1);
e32(nr);
for (i = 0; i + 1 < nr; i += 2) {
e32((rmesa->state.aos[i].aos_size << 0)
| (rmesa->state.aos[i].aos_stride << 8)
| (rmesa->state.aos[i + 1].aos_size << 16)
| (rmesa->state.aos[i + 1].aos_stride << 24)
);
e32(rmesa->state.aos[i].aos_offset +
offset * 4 * rmesa->state.aos[i].aos_stride);
e32(rmesa->state.aos[i + 1].aos_offset +
offset * 4 * rmesa->state.aos[i + 1].aos_stride);
}
if(num_verts > 65535){ /* not implemented yet */
WARN_ONCE("Too many elts\n");
return;
if (nr & 1) {
e32((rmesa->state.aos[nr - 1].aos_size << 0)
| (rmesa->state.aos[nr - 1].aos_stride << 8)
);
e32(rmesa->state.aos[nr - 1].aos_offset +
offset * 4 * rmesa->state.aos[nr - 1].aos_stride);
}
r300EmitElts(ctx, rmesa->state.VB.Elts, num_verts, rmesa->state.VB.elt_size);
fire_EB(rmesa, rmesa->state.elt_dma.aos_offset, num_verts, type, rmesa->state.VB.elt_size);
#endif
}else{
r300EmitAOS(rmesa, rmesa->state.aos_count, start);
fire_AOS(rmesa, num_verts, type);
}
}
GLboolean r300_run_vb_render(GLcontext *ctx,
struct tnl_pipeline_stage *stage)
static void r300FireAOS(r300ContextPtr rmesa, int vertex_count, int type)
{
int cmd_reserved = 0;
int cmd_written = 0;
drm_radeon_cmd_header_t *cmd = NULL;
start_packet3(RADEON_CP_PACKET3_3D_DRAW_VBUF_2, 0);
e32(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (vertex_count << 16)
| type);
}
static void r300RunRenderPrimitive(r300ContextPtr rmesa, GLcontext * ctx,
int start, int end, int prim)
{
int type, num_verts;
type = r300PrimitiveType(rmesa, ctx, prim);
num_verts = r300NumVerts(rmesa, end - start, prim);
if (type < 0 || num_verts <= 0)
return;
if (rmesa->state.VB.Elts) {
r300EmitAOS(rmesa, rmesa->state.aos_count, start);
if (num_verts > 65535) {
/* not implemented yet */
WARN_ONCE("Too many elts\n");
return;
}
r300EmitElts(ctx, rmesa->state.VB.Elts, num_verts,
rmesa->state.VB.elt_size);
r300FireEB(rmesa, rmesa->state.elt_dma.aos_offset,
num_verts, type, rmesa->state.VB.elt_size);
} else {
r300EmitAOS(rmesa, rmesa->state.aos_count, start);
r300FireAOS(rmesa, num_verts, type);
}
}
#define CONV_VB(a, b) rvb->AttribPtr[(a)].size = vb->b->size, \
rvb->AttribPtr[(a)].type = GL_FLOAT, \
rvb->AttribPtr[(a)].stride = vb->b->stride, \
rvb->AttribPtr[(a)].data = vb->b->data
static void radeon_vb_to_rvb(r300ContextPtr rmesa,
struct radeon_vertex_buffer *rvb,
struct vertex_buffer *vb)
{
int i;
GLcontext *ctx;
ctx = rmesa->radeon.glCtx;
memset(rvb, 0, sizeof(*rvb));
rvb->Elts = vb->Elts;
rvb->elt_size = 4;
rvb->elt_min = 0;
rvb->elt_max = vb->Count;
rvb->Count = vb->Count;
if (hw_tcl_on) {
CONV_VB(VERT_ATTRIB_POS, ObjPtr);
} else {
assert(vb->ClipPtr);
CONV_VB(VERT_ATTRIB_POS, ClipPtr);
}
CONV_VB(VERT_ATTRIB_NORMAL, NormalPtr);
CONV_VB(VERT_ATTRIB_COLOR0, ColorPtr[0]);
CONV_VB(VERT_ATTRIB_COLOR1, SecondaryColorPtr[0]);
CONV_VB(VERT_ATTRIB_FOG, FogCoordPtr);
for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++)
CONV_VB(VERT_ATTRIB_TEX0 + i, TexCoordPtr[i]);
for (i = 0; i < MAX_VERTEX_PROGRAM_ATTRIBS; i++)
CONV_VB(VERT_ATTRIB_GENERIC0 + i,
AttribPtr[VERT_ATTRIB_GENERIC0 + i]);
rvb->Primitive = vb->Primitive;
rvb->PrimitiveCount = vb->PrimitiveCount;
rvb->LockFirst = rvb->LockCount = 0;
rvb->lock_uptodate = GL_FALSE;
}
static GLboolean r300RunRender(GLcontext * ctx,
struct tnl_pipeline_stage *stage)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct radeon_vertex_buffer *VB = &rmesa->state.VB;
@@ -328,12 +382,11 @@ GLboolean r300_run_vb_render(GLcontext *ctx,
int cmd_written = 0;
drm_radeon_cmd_header_t *cmd = NULL;
if (RADEON_DEBUG & DEBUG_PRIMS)
fprintf(stderr, "%s\n", __FUNCTION__);
if (stage) {
TNLcontext *tnl = TNL_CONTEXT(ctx);
TNLcontext *tnl = TNL_CONTEXT(ctx);
radeon_vb_to_rvb(rmesa, VB, &tnl->vb);
}
@@ -343,32 +396,33 @@ GLboolean r300_run_vb_render(GLcontext *ctx,
r300UpdateShaderStates(rmesa);
reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
reg_start(R300_RB3D_DSTCACHE_CTLSTAT, 0);
e32(R300_RB3D_DSTCACHE_UNKNOWN_0A);
reg_start(R300_RB3D_ZCACHE_CTLSTAT,0);
reg_start(R300_RB3D_ZCACHE_CTLSTAT, 0);
e32(R300_RB3D_ZCACHE_UNKNOWN_03);
r300EmitState(rmesa);
for(i=0; i < VB->PrimitiveCount; i++){
for (i = 0; i < VB->PrimitiveCount; i++) {
GLuint prim = _tnl_translate_prim(&VB->Primitive[i]);
GLuint start = VB->Primitive[i].start;
GLuint length = VB->Primitive[i].count;
r300_render_vb_primitive(rmesa, ctx, start, start + length, prim);
GLuint end = VB->Primitive[i].start + VB->Primitive[i].count;
r300RunRenderPrimitive(rmesa, ctx, start, end, prim);
}
reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
e32(R300_RB3D_DSTCACHE_UNKNOWN_0A /*R300_RB3D_DSTCACHE_UNKNOWN_02*/);
reg_start(R300_RB3D_DSTCACHE_CTLSTAT, 0);
e32(R300_RB3D_DSTCACHE_UNKNOWN_0A);
reg_start(R300_RB3D_ZCACHE_CTLSTAT,0);
e32(R300_RB3D_ZCACHE_UNKNOWN_03 /*R300_RB3D_ZCACHE_UNKNOWN_01*/);
reg_start(R300_RB3D_ZCACHE_CTLSTAT, 0);
e32(R300_RB3D_ZCACHE_UNKNOWN_03);
#ifdef USER_BUFFERS
r300UseArrays(ctx);
#endif
r300ReleaseArrays(ctx);
return GL_FALSE;
}
@@ -382,118 +436,69 @@ GLboolean r300_run_vb_render(GLcontext *ctx,
} \
} while(0)
int r300Fallback(GLcontext *ctx)
static int r300Fallback(GLcontext * ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
struct r300_fragment_program *rp =
(struct r300_fragment_program *)
(char *)ctx->FragmentProgram._Current;
struct r300_fragment_program *fp = (struct r300_fragment_program *)
(char *)ctx->FragmentProgram._Current;
if (rp) {
if (!rp->translated)
r300_translate_fragment_shader(r300, rp);
FALLBACK_IF(!rp->translated);
if (fp) {
if (!fp->translated)
r300TranslateFragmentShader(r300, fp);
FALLBACK_IF(!fp->translated);
}
/* We do not do SELECT or FEEDBACK (yet ?)
* Is it worth doing them ?
*/
FALLBACK_IF(ctx->RenderMode != GL_RENDER);
#if 0
/* These should work now.. */
FALLBACK_IF(ctx->Color.DitherFlag);
/* GL_ALPHA_TEST */
FALLBACK_IF(ctx->Color.AlphaEnabled);
/* GL_BLEND */
FALLBACK_IF(ctx->Color.BlendEnabled);
/* GL_POLYGON_OFFSET_FILL */
FALLBACK_IF(ctx->Polygon.OffsetFill);
/* FOG seems to trigger an unknown output
* in vertex program.
*/
FALLBACK_IF(ctx->Fog.Enabled);
#endif
FALLBACK_IF(ctx->Stencil._TestTwoSide &&
(ctx->Stencil.Ref[0] != ctx->Stencil.Ref[1] ||
ctx->Stencil.ValueMask[0] != ctx->Stencil.ValueMask[1] ||
ctx->Stencil.WriteMask[0] != ctx->Stencil.WriteMask[1]));
FALLBACK_IF(ctx->Stencil._TestTwoSide
&& (ctx->Stencil.Ref[0] != ctx->Stencil.Ref[1]
|| ctx->Stencil.ValueMask[0] !=
ctx->Stencil.ValueMask[1]
|| ctx->Stencil.WriteMask[0] !=
ctx->Stencil.WriteMask[1]));
if(!r300->disable_lowimpact_fallback){
/* GL_POLYGON_OFFSET_POINT */
FALLBACK_IF(ctx->Polygon.OffsetPoint);
/* GL_POLYGON_OFFSET_LINE */
FALLBACK_IF(ctx->Polygon.OffsetLine);
#if 0
/* GL_STENCIL_TEST */
FALLBACK_IF(ctx->Stencil.Enabled);
/* GL_POLYGON_SMOOTH disabling to get blender going */
FALLBACK_IF(ctx->Polygon.SmoothFlag);
#endif
/* GL_POLYGON_STIPPLE */
FALLBACK_IF(ctx->Polygon.StippleFlag);
/* GL_MULTISAMPLE_ARB */
FALLBACK_IF(ctx->Multisample.Enabled);
/* blender ? */
FALLBACK_IF(ctx->Line.StippleFlag);
/* GL_LINE_SMOOTH */
FALLBACK_IF(ctx->Line.SmoothFlag);
/* GL_POINT_SMOOTH */
FALLBACK_IF(ctx->Point.SmoothFlag);
}
/* Fallback for LOGICOP */
FALLBACK_IF(ctx->Color.ColorLogicOpEnabled);
/* Rest could be done with vertex fragments */
if (ctx->Extensions.NV_point_sprite ||
ctx->Extensions.ARB_point_sprite)
/* GL_POINT_SPRITE_NV */
if (ctx->Extensions.NV_point_sprite || ctx->Extensions.ARB_point_sprite)
FALLBACK_IF(ctx->Point.PointSprite);
if (!r300->disable_lowimpact_fallback) {
FALLBACK_IF(ctx->Polygon.OffsetPoint);
FALLBACK_IF(ctx->Polygon.OffsetLine);
FALLBACK_IF(ctx->Polygon.StippleFlag);
FALLBACK_IF(ctx->Multisample.Enabled);
FALLBACK_IF(ctx->Line.StippleFlag);
FALLBACK_IF(ctx->Line.SmoothFlag);
FALLBACK_IF(ctx->Point.SmoothFlag);
}
return R300_FALLBACK_NONE;
}
/**
* Called by the pipeline manager to render a batch of primitives.
* We can return true to pass on to the next stage (i.e. software
* rasterization) or false to indicate that the pipeline has finished
* after we render something.
*/
static GLboolean r300_run_render(GLcontext *ctx,
struct tnl_pipeline_stage *stage)
static GLboolean r300RunNonTCLRender(GLcontext * ctx,
struct tnl_pipeline_stage *stage)
{
if (RADEON_DEBUG & DEBUG_PRIMS)
fprintf(stderr, "%s\n", __FUNCTION__);
if (r300Fallback(ctx) >= R300_FALLBACK_RAST)
return GL_TRUE;
return r300_run_vb_render(ctx, stage);
return r300RunRender(ctx, stage);
}
const struct tnl_pipeline_stage _r300_render_stage = {
"r300 hw rasterize",
NULL,
NULL,
NULL,
NULL,
r300_run_render /* run */
};
static GLboolean r300_run_tcl_render(GLcontext *ctx,
struct tnl_pipeline_stage *stage)
static GLboolean r300RunTCLRender(GLcontext * ctx,
struct tnl_pipeline_stage *stage)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct r300_vertex_program *vp;
hw_tcl_on=future_hw_tcl_on;
hw_tcl_on = future_hw_tcl_on;
if (RADEON_DEBUG & DEBUG_PRIMS)
fprintf(stderr, "%s\n", __FUNCTION__);
if(hw_tcl_on == GL_FALSE)
if (hw_tcl_on == GL_FALSE)
return GL_TRUE;
if (r300Fallback(ctx) >= R300_FALLBACK_TCL) {
@@ -504,42 +509,28 @@ static GLboolean r300_run_tcl_render(GLcontext *ctx,
r300UpdateShaders(rmesa);
vp = (struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx);
#if 0 /* Draw every second request with software arb vp */
vp->native++;
vp->native &= 1;
//vp->native = GL_FALSE;
#endif
#if 0 /* You dont want to know what this does... */
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct tnl_cache *cache;
struct tnl_cache_item *c;
cache = tnl->vp_cache;
c = cache->items[0xc000cc0e % cache->size];
if(c && c->data == vp)
vp->native = GL_FALSE;
#endif
#if 0
vp->native = GL_FALSE;
#endif
if (vp->native == GL_FALSE) {
hw_tcl_on = GL_FALSE;
return GL_TRUE;
}
//r300UpdateShaderStates(rmesa);
return r300_run_vb_render(ctx, stage);
return r300RunRender(ctx, stage);
}
const struct tnl_pipeline_stage _r300_tcl_stage = {
"r300 tcl",
const struct tnl_pipeline_stage _r300_render_stage = {
"r300 Hardware Rasterization",
NULL,
NULL,
NULL,
NULL,
r300_run_tcl_render /* run */
r300RunNonTCLRender
};
const struct tnl_pipeline_stage _r300_tcl_stage = {
"r300 Hardware Transform, Clipping and Lighting",
NULL,
NULL,
NULL,
NULL,
r300RunTCLRender
};

View File

@@ -7,82 +7,67 @@
#include "r300_context.h"
#include "r300_fragprog.h"
static void
r300BindProgram(GLcontext *ctx, GLenum target, struct gl_program *prog)
{
switch(target){
case GL_VERTEX_PROGRAM_ARB:
case GL_FRAGMENT_PROGRAM_ARB:
break;
default:
WARN_ONCE("Target not supported yet!\n");
break;
}
}
static struct gl_program *
r300NewProgram(GLcontext *ctx, GLenum target, GLuint id)
static struct gl_program *r300NewProgram(GLcontext * ctx, GLenum target,
GLuint id)
{
struct r300_vertex_program_cont *vp;
struct r300_fragment_program *fp;
switch(target){
case GL_VERTEX_STATE_PROGRAM_NV:
case GL_VERTEX_PROGRAM_ARB:
vp=CALLOC_STRUCT(r300_vertex_program_cont);
return _mesa_init_vertex_program(ctx, &vp->mesa_program, target, id);
case GL_FRAGMENT_PROGRAM_ARB:
fp=CALLOC_STRUCT(r300_fragment_program);
fp->ctx = ctx;
return _mesa_init_fragment_program(ctx, &fp->mesa_program, target, id);
case GL_FRAGMENT_PROGRAM_NV:
fp=CALLOC_STRUCT(r300_fragment_program);
return _mesa_init_fragment_program(ctx, &fp->mesa_program, target, id);
default:
_mesa_problem(ctx, "Bad target in r300NewProgram");
switch (target) {
case GL_VERTEX_STATE_PROGRAM_NV:
case GL_VERTEX_PROGRAM_ARB:
vp = CALLOC_STRUCT(r300_vertex_program_cont);
return _mesa_init_vertex_program(ctx, &vp->mesa_program,
target, id);
case GL_FRAGMENT_PROGRAM_ARB:
fp = CALLOC_STRUCT(r300_fragment_program);
fp->ctx = ctx;
return _mesa_init_fragment_program(ctx, &fp->mesa_program,
target, id);
case GL_FRAGMENT_PROGRAM_NV:
fp = CALLOC_STRUCT(r300_fragment_program);
return _mesa_init_fragment_program(ctx, &fp->mesa_program,
target, id);
default:
_mesa_problem(ctx, "Bad target in r300NewProgram");
}
return NULL;
return NULL;
}
static void
r300DeleteProgram(GLcontext *ctx, struct gl_program *prog)
static void r300DeleteProgram(GLcontext * ctx, struct gl_program *prog)
{
_mesa_delete_program(ctx, prog);
}
static void
r300ProgramStringNotify(GLcontext *ctx, GLenum target, struct gl_program *prog)
r300ProgramStringNotify(GLcontext * ctx, GLenum target, struct gl_program *prog)
{
struct r300_vertex_program_cont *vp=(void *)prog;
struct r300_fragment_program *fp = (struct r300_fragment_program *) prog;
switch(target) {
struct r300_vertex_program_cont *vp = (void *)prog;
struct r300_fragment_program *fp = (struct r300_fragment_program *)prog;
switch (target) {
case GL_VERTEX_PROGRAM_ARB:
vp->progs = NULL;
/*vp->translated = GL_FALSE;
memset(&vp->translated, 0, sizeof(struct r300_vertex_program) - sizeof(struct gl_vertex_program));*/
/*r300_translate_vertex_shader(vp);*/
break;
break;
case GL_FRAGMENT_PROGRAM_ARB:
fp->translated = GL_FALSE;
break;
break;
}
/* need this for tcl fallbacks */
_tnl_program_string(ctx, target, prog);
}
static GLboolean
r300IsProgramNative(GLcontext *ctx, GLenum target, struct gl_program *prog)
r300IsProgramNative(GLcontext * ctx, GLenum target, struct gl_program *prog)
{
return 1;
}
void r300InitShaderFuncs(struct dd_function_table *functions)
{
functions->NewProgram=r300NewProgram;
functions->BindProgram=r300BindProgram;
functions->DeleteProgram=r300DeleteProgram;
functions->ProgramStringNotify=r300ProgramStringNotify;
functions->IsProgramNative=r300IsProgramNative;
functions->NewProgram = r300NewProgram;
functions->DeleteProgram = r300DeleteProgram;
functions->ProgramStringNotify = r300ProgramStringNotify;
functions->IsProgramNative = r300IsProgramNative;
}

File diff suppressed because it is too large Load Diff

View File

@@ -44,7 +44,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
} while(0)
#define R300_PRINT_STATE(r300, atom) \
r300_print_state_atom(r300, &r300->hw.atom)
r300PrintStateAtom(r300, &r300->hw.atom)
/* Fire the buffered vertices no matter what.
TODO: This has not been implemented yet
@@ -58,23 +58,13 @@ do { \
\
} while (0)
extern void r300ResetHwState(r300ContextPtr r300);
extern void r300UpdateStateParameters(GLcontext * ctx, GLuint new_state);
extern void r300InitState(r300ContextPtr r300);
extern void r300InitStateFuncs(struct dd_function_table* functions);
extern void r300UpdateViewportOffset( GLcontext *ctx );
extern void r300UpdateWindow(GLcontext * ctx);
extern void r300UpdateDrawBuffer(GLcontext *ctx);
extern void r300SetupVertexShader(r300ContextPtr rmesa);
extern void r300SetupPixelShader(r300ContextPtr rmesa);
extern void r300InitStateFuncs(struct dd_function_table *functions);
extern void r300UpdateViewportOffset(GLcontext * ctx);
extern void r300UpdateDrawBuffer(GLcontext * ctx);
extern void r300_setup_textures(GLcontext *ctx);
extern void r300_setup_rs_unit(GLcontext *ctx);
extern void r300UpdateShaders(r300ContextPtr rmesa);
extern void r300UpdateShaderStates(r300ContextPtr rmesa);
extern void r300_print_state_atom(r300ContextPtr r300, struct r300_state_atom *state);
#endif /* __R300_STATE_H__ */
#endif /* __R300_STATE_H__ */

View File

@@ -26,9 +26,10 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
/**
* \file
*
* \author Keith Whitwell <keith@tungstengraphics.com>
*/
#include "glheader.h"
@@ -47,7 +48,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r300_context.h"
#include "r300_state.h"
#include "r300_ioctl.h"
//#include "r300_swtcl.h"
#include "r300_tex.h"
#include "xmlpool.h"
@@ -63,7 +63,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
static void r300SetTexWrap(r300TexObjPtr t, GLenum swrap, GLenum twrap,
GLenum rwrap)
{
unsigned long hw_swrap=0, hw_twrap=0, hw_qwrap=0;
unsigned long hw_swrap = 0, hw_twrap = 0, hw_qwrap = 0;
t->filter &=
~(R300_TX_WRAP_S_MASK | R300_TX_WRAP_T_MASK | R300_TX_WRAP_Q_MASK);
@@ -158,11 +158,6 @@ static void r300SetTexWrap(r300TexObjPtr t, GLenum swrap, GLenum twrap,
t->filter |= hw_swrap << R300_TX_WRAP_S_SHIFT;
t->filter |= hw_twrap << R300_TX_WRAP_T_SHIFT;
t->filter |= hw_qwrap << R300_TX_WRAP_Q_SHIFT;
#if 0
t->format_x &= ~R200_CLAMP_Q_MASK;
t->border_fallback = (is_clamp && is_clamp_to_border);
#endif
}
static void r300SetTexMaxAnisotropy(r300TexObjPtr t, GLfloat max)
@@ -196,9 +191,6 @@ static void r300SetTexFilter(r300TexObjPtr t, GLenum minf, GLenum magf)
GLuint anisotropy = (t->filter & R300_TX_MAX_ANISO_MASK);
t->filter &= ~(R300_TX_MIN_FILTER_MASK | R300_TX_MAG_FILTER_MASK);
#if 0
//t->format_x &= ~R200_VOLUME_FILTER_MASK;
#endif
if (anisotropy == R300_TX_MAX_ANISO_1_TO_1) {
switch (minf) {
@@ -232,12 +224,12 @@ static void r300SetTexFilter(r300TexObjPtr t, GLenum minf, GLenum magf)
case GL_NEAREST_MIPMAP_NEAREST:
case GL_LINEAR_MIPMAP_NEAREST:
t->filter |=
R300_TX_MIN_FILTER_ANISO_NEAREST_MIP_NEAREST;
R300_TX_MIN_FILTER_ANISO_NEAREST_MIP_NEAREST;
break;
case GL_NEAREST_MIPMAP_LINEAR:
case GL_LINEAR_MIPMAP_LINEAR:
t->filter |=
R300_TX_MIN_FILTER_ANISO_NEAREST_MIP_LINEAR;
R300_TX_MIN_FILTER_ANISO_NEAREST_MIP_LINEAR;
break;
}
}
@@ -248,18 +240,16 @@ static void r300SetTexFilter(r300TexObjPtr t, GLenum minf, GLenum magf)
switch (magf) {
case GL_NEAREST:
t->filter |= R300_TX_MAG_FILTER_NEAREST;
/*t->format_x |= R200_VOLUME_FILTER_NEAREST;*/
break;
case GL_LINEAR:
t->filter |= R300_TX_MAG_FILTER_LINEAR;
/*t->format_x |= R200_VOLUME_FILTER_LINEAR;*/
break;
}
}
static void r300SetTexBorderColor(r300TexObjPtr t, GLubyte c[4])
{
t->pp_border_color = r300PackColor(4, c[0], c[1], c[2], c[3]);
t->pp_border_color = PACK_COLOR_8888(c[0], c[1], c[2], c[3]);
}
/**
@@ -297,35 +287,37 @@ static r300TexObjPtr r300AllocTexObj(struct gl_texture_object *texObj)
}
/* try to find a format which will only need a memcopy */
static const struct gl_texture_format *r300Choose8888TexFormat( GLenum srcFormat,
GLenum srcType )
static const struct gl_texture_format *r300Choose8888TexFormat(GLenum srcFormat,
GLenum srcType)
{
const GLuint ui = 1;
const GLubyte littleEndian = *((const GLubyte *) &ui);
const GLubyte littleEndian = *((const GLubyte *)&ui);
if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
(srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
(srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
(srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && littleEndian)) {
(srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE
&& !littleEndian) || (srcFormat == GL_ABGR_EXT
&& srcType == GL_UNSIGNED_INT_8_8_8_8_REV)
|| (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE
&& littleEndian)) {
return &_mesa_texformat_rgba8888;
}
else if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
(srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && littleEndian) ||
(srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
(srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && !littleEndian)) {
} else
if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV)
|| (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE
&& littleEndian) || (srcFormat == GL_ABGR_EXT
&& srcType == GL_UNSIGNED_INT_8_8_8_8)
|| (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE
&& !littleEndian)) {
return &_mesa_texformat_rgba8888_rev;
}
else if (srcFormat == GL_BGRA &&
((srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
srcType == GL_UNSIGNED_INT_8_8_8_8)) {
} else if (srcFormat == GL_BGRA &&
((srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
srcType == GL_UNSIGNED_INT_8_8_8_8)) {
return &_mesa_texformat_argb8888_rev;
}
else if (srcFormat == GL_BGRA &&
((srcType == GL_UNSIGNED_BYTE && littleEndian) ||
srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) {
} else if (srcFormat == GL_BGRA &&
((srcType == GL_UNSIGNED_BYTE && littleEndian) ||
srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) {
return &_mesa_texformat_argb8888;
}
else return _dri_texformat_argb8888;
} else
return _dri_texformat_argb8888;
}
static const struct gl_texture_format *r300ChooseTextureFormat(GLcontext * ctx,
@@ -344,10 +336,8 @@ static const struct gl_texture_format *r300ChooseTextureFormat(GLcontext * ctx,
#if 0
fprintf(stderr, "InternalFormat=%s(%d) type=%s format=%s\n",
_mesa_lookup_enum_by_nr(internalFormat), internalFormat,
_mesa_lookup_enum_by_nr(type),
_mesa_lookup_enum_by_nr(format));
fprintf(stderr, "do32bpt=%d force16bpt=%d\n",
do32bpt, force16bpt);
_mesa_lookup_enum_by_nr(type), _mesa_lookup_enum_by_nr(format));
fprintf(stderr, "do32bpt=%d force16bpt=%d\n", do32bpt, force16bpt);
#endif
switch (internalFormat) {
@@ -393,7 +383,8 @@ static const struct gl_texture_format *r300ChooseTextureFormat(GLcontext * ctx,
case GL_RGBA12:
case GL_RGBA16:
return !force16bpt ?
r300Choose8888TexFormat(format, type) : _dri_texformat_argb4444;
r300Choose8888TexFormat(format,
type) : _dri_texformat_argb4444;
case GL_RGBA4:
case GL_RGBA2:
@@ -460,43 +451,43 @@ static const struct gl_texture_format *r300ChooseTextureFormat(GLcontext * ctx,
case GL_RGB_S3TC:
case GL_RGB4_S3TC:
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
return &_mesa_texformat_rgb_dxt1;
return &_mesa_texformat_rgb_dxt1;
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
return &_mesa_texformat_rgba_dxt1;
return &_mesa_texformat_rgba_dxt1;
case GL_RGBA_S3TC:
case GL_RGBA4_S3TC:
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
return &_mesa_texformat_rgba_dxt3;
return &_mesa_texformat_rgba_dxt3;
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
return &_mesa_texformat_rgba_dxt5;
case GL_ALPHA16F_ARB:
return &_mesa_texformat_alpha_float16;
return &_mesa_texformat_rgba_dxt5;
case GL_ALPHA16F_ARB:
return &_mesa_texformat_alpha_float16;
case GL_ALPHA32F_ARB:
return &_mesa_texformat_alpha_float32;
return &_mesa_texformat_alpha_float32;
case GL_LUMINANCE16F_ARB:
return &_mesa_texformat_luminance_float16;
return &_mesa_texformat_luminance_float16;
case GL_LUMINANCE32F_ARB:
return &_mesa_texformat_luminance_float32;
return &_mesa_texformat_luminance_float32;
case GL_LUMINANCE_ALPHA16F_ARB:
return &_mesa_texformat_luminance_alpha_float16;
return &_mesa_texformat_luminance_alpha_float16;
case GL_LUMINANCE_ALPHA32F_ARB:
return &_mesa_texformat_luminance_alpha_float32;
return &_mesa_texformat_luminance_alpha_float32;
case GL_INTENSITY16F_ARB:
return &_mesa_texformat_intensity_float16;
return &_mesa_texformat_intensity_float16;
case GL_INTENSITY32F_ARB:
return &_mesa_texformat_intensity_float32;
return &_mesa_texformat_intensity_float32;
case GL_RGB16F_ARB:
return &_mesa_texformat_rgba_float16;
return &_mesa_texformat_rgba_float16;
case GL_RGB32F_ARB:
return &_mesa_texformat_rgba_float32;
return &_mesa_texformat_rgba_float32;
case GL_RGBA16F_ARB:
return &_mesa_texformat_rgba_float16;
return &_mesa_texformat_rgba_float16;
case GL_RGBA32F_ARB:
return &_mesa_texformat_rgba_float32;
return &_mesa_texformat_rgba_float32;
default:
_mesa_problem(ctx,
@@ -519,7 +510,7 @@ r300ValidateClientStorage(GLcontext * ctx, GLenum target,
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
if (0)
if (RADEON_DEBUG & DEBUG_TEXTURE)
fprintf(stderr, "intformat %s format %s type %s\n",
_mesa_lookup_enum_by_nr(internalFormat),
_mesa_lookup_enum_by_nr(format),
@@ -576,7 +567,7 @@ r300ValidateClientStorage(GLcontext * ctx, GLenum target,
GLint srcRowStride = _mesa_image_row_stride(packing, srcWidth,
format, type);
if (0)
if (RADEON_DEBUG & DEBUG_TEXTURE)
fprintf(stderr, "%s: srcRowStride %d/%x\n",
__FUNCTION__, srcRowStride, srcRowStride);
@@ -771,116 +762,123 @@ static void r300TexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
t->dirty_images[face] |= (1 << level);
}
static void r300CompressedTexImage2D( GLcontext *ctx, GLenum target, GLint level,
GLint internalFormat,
GLint width, GLint height, GLint border,
GLsizei imageSize, const GLvoid *data,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage )
static void r300CompressedTexImage2D(GLcontext * ctx, GLenum target,
GLint level, GLint internalFormat,
GLint width, GLint height, GLint border,
GLsizei imageSize, const GLvoid * data,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
driTextureObject * t = (driTextureObject *) texObj->DriverData;
GLuint face;
driTextureObject *t = (driTextureObject *) texObj->DriverData;
GLuint face;
/* which cube face or ordinary 2D image */
switch (target) {
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
ASSERT(face < 6);
break;
default:
face = 0;
}
/* which cube face or ordinary 2D image */
switch (target) {
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
face =
(GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
ASSERT(face < 6);
break;
default:
face = 0;
}
if ( t != NULL ) {
driSwapOutTextureObject( t );
}
else {
t = (driTextureObject *) r300AllocTexObj( texObj );
if (!t) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
return;
}
}
if (t != NULL) {
driSwapOutTextureObject(t);
} else {
t = (driTextureObject *) r300AllocTexObj(texObj);
if (!t) {
_mesa_error(ctx, GL_OUT_OF_MEMORY,
"glCompressedTexImage2D");
return;
}
}
texImage->IsClientData = GL_FALSE;
/* can't call this, different parameters. Would never evaluate to true anyway currently
if (r300ValidateClientStorage( ctx, target,
internalFormat,
width, height,
format, type, pixels,
packing, texObj, texImage)) {
if (RADEON_DEBUG & DEBUG_TEXTURE)
fprintf(stderr, "%s: Using client storage\n", __FUNCTION__);
}
else */{
if (RADEON_DEBUG & DEBUG_TEXTURE)
fprintf(stderr, "%s: Using normal storage\n", __FUNCTION__);
texImage->IsClientData = GL_FALSE;
/* Normal path: copy (to cached memory) and eventually upload
* via another copy to GART memory and then a blit... Could
* eliminate one copy by going straight to (permanent) GART.
*
* Note, this will call r300ChooseTextureFormat.
*/
_mesa_store_compressed_teximage2d(ctx, target, level, internalFormat, width,
height, border, imageSize, data, texObj, texImage);
/* can't call this, different parameters. Would never evaluate to true anyway currently */
#if 0
if (r300ValidateClientStorage(ctx, target,
internalFormat,
width, height,
format, type, pixels,
packing, texObj, texImage)) {
if (RADEON_DEBUG & DEBUG_TEXTURE)
fprintf(stderr, "%s: Using client storage\n",
__FUNCTION__);
} else
#endif
{
if (RADEON_DEBUG & DEBUG_TEXTURE)
fprintf(stderr, "%s: Using normal storage\n",
__FUNCTION__);
t->dirty_images[face] |= (1 << level);
}
/* Normal path: copy (to cached memory) and eventually upload
* via another copy to GART memory and then a blit... Could
* eliminate one copy by going straight to (permanent) GART.
*
* Note, this will call r300ChooseTextureFormat.
*/
_mesa_store_compressed_teximage2d(ctx, target, level,
internalFormat, width, height,
border, imageSize, data,
texObj, texImage);
t->dirty_images[face] |= (1 << level);
}
}
static void r300CompressedTexSubImage2D( GLcontext *ctx, GLenum target, GLint level,
GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height,
GLenum format,
GLsizei imageSize, const GLvoid *data,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage )
static void r300CompressedTexSubImage2D(GLcontext * ctx, GLenum target,
GLint level, GLint xoffset,
GLint yoffset, GLsizei width,
GLsizei height, GLenum format,
GLsizei imageSize, const GLvoid * data,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
driTextureObject * t = (driTextureObject *) texObj->DriverData;
GLuint face;
driTextureObject *t = (driTextureObject *) texObj->DriverData;
GLuint face;
/* which cube face or ordinary 2D image */
switch (target) {
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
face =
(GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
ASSERT(face < 6);
break;
default:
face = 0;
}
/* which cube face or ordinary 2D image */
switch (target) {
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
ASSERT(face < 6);
break;
default:
face = 0;
}
assert(t); /* this _should_ be true */
if (t) {
driSwapOutTextureObject(t);
} else {
t = (driTextureObject *) r300AllocTexObj(texObj);
if (!t) {
_mesa_error(ctx, GL_OUT_OF_MEMORY,
"glCompressedTexSubImage3D");
return;
}
}
assert( t ); /* this _should_ be true */
if ( t ) {
driSwapOutTextureObject( t );
}
else {
t = (driTextureObject *) r300AllocTexObj( texObj );
if (!t) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3D");
return;
}
}
_mesa_store_compressed_texsubimage2d(ctx, target, level, xoffset,
yoffset, width, height, format,
imageSize, data, texObj, texImage);
_mesa_store_compressed_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
height, format, imageSize, data, texObj, texImage);
t->dirty_images[face] |= (1 << level);
t->dirty_images[face] |= (1 << level);
}
#if ENABLE_HW_3D_TEXTURE
static void r300TexImage3D(GLcontext * ctx, GLenum target, GLint level,
GLint internalFormat,
GLint width, GLint height, GLint depth,
@@ -934,9 +932,7 @@ static void r300TexImage3D(GLcontext * ctx, GLenum target, GLint level,
t->dirty_images[0] |= (1 << level);
}
}
#endif
#if ENABLE_HW_3D_TEXTURE
static void
r300TexSubImage3D(GLcontext * ctx, GLenum target, GLint level,
GLint xoffset, GLint yoffset, GLint zoffset,
@@ -970,7 +966,6 @@ r300TexSubImage3D(GLcontext * ctx, GLenum target, GLint level,
t->dirty_images[0] |= (1 << level);
}
#endif
static void r300TexEnv(GLcontext * ctx, GLenum target,
GLenum pname, const GLfloat * param)
@@ -986,7 +981,7 @@ static void r300TexEnv(GLcontext * ctx, GLenum target,
*/
switch (pname) {
case GL_TEXTURE_LOD_BIAS_EXT:{
#if 0 /* Needs to be relocated in order to make sure we got the right tmu */
#if 0 /* Needs to be relocated in order to make sure we got the right tmu */
GLfloat bias, min;
GLuint b;
@@ -1006,10 +1001,16 @@ static void r300TexEnv(GLcontext * ctx, GLenum target,
b = 0x1000 / 16.0 * bias;
b &= R300_LOD_BIAS_MASK;
if(b != (rmesa->hw.tex.unknown1.cmd[R300_TEX_VALUE_0+unit] & R300_LOD_BIAS_MASK)){
if (b !=
(rmesa->hw.tex.unknown1.
cmd[R300_TEX_VALUE_0 +
unit] & R300_LOD_BIAS_MASK)) {
R300_STATECHANGE(rmesa, tex.unknown1);
rmesa->hw.tex.unknown1.cmd[R300_TEX_VALUE_0+unit] &= ~R300_LOD_BIAS_MASK;
rmesa->hw.tex.unknown1.cmd[R300_TEX_VALUE_0+unit] |= b;
rmesa->hw.tex.unknown1.cmd[R300_TEX_VALUE_0 +
unit] &=
~R300_LOD_BIAS_MASK;
rmesa->hw.tex.unknown1.cmd[R300_TEX_VALUE_0 +
unit] |= b;
}
#endif
break;
@@ -1085,9 +1086,7 @@ static void r300BindTexture(GLcontext * ctx, GLenum target,
if ((target == GL_TEXTURE_1D)
|| (target == GL_TEXTURE_2D)
#if ENABLE_HW_3D_TEXTURE
|| (target == GL_TEXTURE_3D)
#endif
|| (target == GL_TEXTURE_CUBE_MAP)
|| (target == GL_TEXTURE_RECTANGLE_NV)) {
assert(texObj->DriverData != NULL);
@@ -1140,7 +1139,6 @@ static struct gl_texture_object *r300NewTextureObject(GLcontext * ctx,
return obj;
}
void r300InitTextureFuncs(struct dd_function_table *functions)
{
/* Note: we only plug in the functions we implement in the driver
@@ -1149,18 +1147,10 @@ void r300InitTextureFuncs(struct dd_function_table *functions)
functions->ChooseTextureFormat = r300ChooseTextureFormat;
functions->TexImage1D = r300TexImage1D;
functions->TexImage2D = r300TexImage2D;
#if ENABLE_HW_3D_TEXTURE
functions->TexImage3D = r300TexImage3D;
#else
functions->TexImage3D = _mesa_store_teximage3d;
#endif
functions->TexSubImage1D = r300TexSubImage1D;
functions->TexSubImage2D = r300TexSubImage2D;
#if ENABLE_HW_3D_TEXTURE
functions->TexSubImage3D = r300TexSubImage3D;
#else
functions->TexSubImage3D = _mesa_store_texsubimage3d;
#endif
functions->NewTextureObject = r300NewTextureObject;
functions->BindTexture = r300BindTexture;
functions->DeleteTexture = r300DeleteTexture;
@@ -1168,23 +1158,9 @@ void r300InitTextureFuncs(struct dd_function_table *functions)
functions->TexEnv = r300TexEnv;
functions->TexParameter = r300TexParameter;
functions->CompressedTexImage2D = r300CompressedTexImage2D;
functions->CompressedTexSubImage2D = r300CompressedTexSubImage2D;
functions->CompressedTexImage2D = r300CompressedTexImage2D;
functions->CompressedTexSubImage2D = r300CompressedTexSubImage2D;
driInitTextureFormats();
#if 0
/* moved or obsolete code */
r300ContextPtr rmesa = R300_CONTEXT(ctx);
driInitTextureObjects(ctx, &rmesa->swapped,
DRI_TEXMGR_DO_TEXTURE_1D
| DRI_TEXMGR_DO_TEXTURE_2D);
/* Hack: r300NewTextureObject is not yet installed when the
* default textures are created. Therefore set MaxAnisotropy of the
* default 2D texture now. */
ctx->Shared->Default2D->MaxAnisotropy =
driQueryOptionf(&rmesa->optionCache, "def_max_anisotropy");
#endif
}

View File

@@ -35,8 +35,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef __r300_TEX_H__
#define __r300_TEX_H__
#ifdef GLX_DIRECT_RENDERING
extern void r300UpdateTextureState(GLcontext * ctx);
extern int r300UploadTexImages(r300ContextPtr rmesa, r300TexObjPtr t,
@@ -46,5 +44,4 @@ extern void r300DestroyTexObj(r300ContextPtr rmesa, r300TexObjPtr t);
extern void r300InitTextureFuncs(struct dd_function_table *functions);
#endif
#endif /* __r300_TEX_H__ */

View File

@@ -28,11 +28,12 @@ SOFTWARE.
**************************************************************************/
/*
* Authors:
* Kevin E. Martin <martin@valinux.com>
* Gareth Hughes <gareth@valinux.com>
/**
* \file
*
* \author Gareth Hughes <gareth@valinux.com>
*
* \author Kevin E. Martin <martin@valinux.com>
*/
#include <errno.h>
@@ -48,15 +49,12 @@ SOFTWARE.
#include "r300_state.h"
#include "r300_cmdbuf.h"
#include "radeon_ioctl.h"
/*
#include "r300_swtcl.h"
*/
#include "r300_tex.h"
#include "r300_ioctl.h"
#include <unistd.h> /* for usleep() */
#ifdef USER_BUFFERS
#include "radeon_mm.h"
#include "r300_mem.h"
#endif
/**
@@ -210,10 +208,8 @@ static void r300UploadRectSubImage(r300ContextPtr rmesa,
/* In this case, could also use GART texturing. This is
* currently disabled, but has been tested & works.
*/
t->offset =
r300GartOffsetFromVirtual(rmesa, texImage->Data);
t->pitch =
texImage->RowStride * texFormat->TexelBytes - 32;
t->offset = r300GartOffsetFromVirtual(rmesa, texImage->Data);
t->pitch = texImage->RowStride * texFormat->TexelBytes - 32;
if (RADEON_DEBUG & DEBUG_TEXTURE)
fprintf(stderr,
@@ -257,7 +253,7 @@ static void r300UploadRectSubImage(r300ContextPtr rmesa,
/* Copy texdata to dma:
*/
if (0)
if (RADEON_DEBUG & DEBUG_TEXTURE)
fprintf(stderr,
"%s: src_pitch %d dst_pitch %d\n",
__FUNCTION__, src_pitch, dstPitch);
@@ -283,14 +279,11 @@ static void r300UploadRectSubImage(r300ContextPtr rmesa,
blit_format,
dstPitch, GET_START(&region),
dstPitch | (t->tile_bits >> 16),
t->bufAddr,
0, 0,
0, done,
width, lines);
t->bufAddr, 0, 0, 0, done, width, lines);
r300EmitWait(rmesa, R300_WAIT_2D);
#ifdef USER_BUFFERS
radeon_mm_use(rmesa, region.buf->id);
r300_mem_use(rmesa, region.buf->id);
#endif
r300ReleaseDmaRegion(rmesa, &region, __FUNCTION__);
@@ -303,10 +296,10 @@ static void r300UploadRectSubImage(r300ContextPtr rmesa,
* Upload the texture image associated with texture \a t at the specified
* level at the address relative to \a start.
*/
static void uploadSubImage( r300ContextPtr rmesa, r300TexObjPtr t,
GLint hwlevel,
GLint x, GLint y, GLint width, GLint height,
GLuint face )
static void r300UploadSubImage(r300ContextPtr rmesa, r300TexObjPtr t,
GLint hwlevel,
GLint x, GLint y, GLint width, GLint height,
GLuint face)
{
struct gl_texture_image *texImage = NULL;
GLuint offset;
@@ -316,71 +309,74 @@ static void uploadSubImage( r300ContextPtr rmesa, r300TexObjPtr t,
drm_radeon_tex_image_t tmp;
const int level = hwlevel + t->base.firstLevel;
if ( RADEON_DEBUG & DEBUG_TEXTURE ) {
fprintf( stderr, "%s( %p, %p ) level/width/height/face = %d/%d/%d/%u\n",
__FUNCTION__, (void *)t, (void *)t->base.tObj,
level, width, height, face );
if (RADEON_DEBUG & DEBUG_TEXTURE) {
fprintf(stderr,
"%s( %p, %p ) level/width/height/face = %d/%d/%d/%u\n",
__FUNCTION__, (void *)t, (void *)t->base.tObj, level,
width, height, face);
}
ASSERT(face < 6);
/* Ensure we have a valid texture to upload */
if ( ( hwlevel < 0 ) || ( hwlevel >= RADEON_MAX_TEXTURE_LEVELS ) ) {
if ((hwlevel < 0) || (hwlevel >= RADEON_MAX_TEXTURE_LEVELS)) {
_mesa_problem(NULL, "bad texture level in %s", __FUNCTION__);
return;
}
texImage = t->base.tObj->Image[face][level];
if ( !texImage ) {
if ( RADEON_DEBUG & DEBUG_TEXTURE )
fprintf( stderr, "%s: texImage %d is NULL!\n", __FUNCTION__, level );
if (!texImage) {
if (RADEON_DEBUG & DEBUG_TEXTURE)
fprintf(stderr, "%s: texImage %d is NULL!\n",
__FUNCTION__, level);
return;
}
if ( !texImage->Data ) {
if ( RADEON_DEBUG & DEBUG_TEXTURE )
fprintf( stderr, "%s: image data is NULL!\n", __FUNCTION__ );
if (!texImage->Data) {
if (RADEON_DEBUG & DEBUG_TEXTURE)
fprintf(stderr, "%s: image data is NULL!\n",
__FUNCTION__);
return;
}
if (t->base.tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
assert(level == 0);
assert(hwlevel == 0);
if ( RADEON_DEBUG & DEBUG_TEXTURE )
fprintf( stderr, "%s: image data is rectangular\n", __FUNCTION__);
r300UploadRectSubImage( rmesa, t, texImage, x, y, width, height );
if (RADEON_DEBUG & DEBUG_TEXTURE)
fprintf(stderr, "%s: image data is rectangular\n",
__FUNCTION__);
r300UploadRectSubImage(rmesa, t, texImage, x, y, width, height);
return;
} else if (texImage->IsClientData) {
if ( RADEON_DEBUG & DEBUG_TEXTURE )
fprintf( stderr, "%s: image data is in GART client storage\n",
__FUNCTION__);
r300UploadGARTClientSubImage( rmesa, t, texImage, hwlevel,
x, y, width, height );
if (RADEON_DEBUG & DEBUG_TEXTURE)
fprintf(stderr,
"%s: image data is in GART client storage\n",
__FUNCTION__);
r300UploadGARTClientSubImage(rmesa, t, texImage, hwlevel, x, y,
width, height);
return;
} else if ( RADEON_DEBUG & DEBUG_TEXTURE )
fprintf( stderr, "%s: image data is in normal memory\n",
} else if (RADEON_DEBUG & DEBUG_TEXTURE)
fprintf(stderr, "%s: image data is in normal memory\n",
__FUNCTION__);
imageWidth = texImage->Width;
imageHeight = texImage->Height;
offset = t->bufAddr + t->base.totalSize / 6 * face;
if ( RADEON_DEBUG & (DEBUG_TEXTURE|DEBUG_IOCTL) ) {
if (RADEON_DEBUG & (DEBUG_TEXTURE | DEBUG_IOCTL)) {
GLint imageX = 0;
GLint imageY = 0;
GLint blitX = t->image[face][hwlevel].x;
GLint blitY = t->image[face][hwlevel].y;
GLint blitWidth = t->image[face][hwlevel].width;
GLint blitHeight = t->image[face][hwlevel].height;
fprintf( stderr, " upload image: %d,%d at %d,%d\n",
imageWidth, imageHeight, imageX, imageY );
fprintf( stderr, " upload blit: %d,%d at %d,%d\n",
blitWidth, blitHeight, blitX, blitY );
fprintf( stderr, " blit ofs: 0x%07x level: %d/%d\n",
(GLuint)offset, hwlevel, level );
fprintf(stderr, " upload image: %d,%d at %d,%d\n",
imageWidth, imageHeight, imageX, imageY);
fprintf(stderr, " upload blit: %d,%d at %d,%d\n",
blitWidth, blitHeight, blitX, blitY);
fprintf(stderr, " blit ofs: 0x%07x level: %d/%d\n",
(GLuint) offset, hwlevel, level);
}
t->image[face][hwlevel].data = texImage->Data;
@@ -395,12 +391,15 @@ static void uploadSubImage( r300ContextPtr rmesa, r300TexObjPtr t,
tex.offset = offset;
tex.image = &tmp;
/* copy (x,y,width,height,data) */
memcpy( &tmp, &t->image[face][hwlevel], sizeof(tmp) );
memcpy(&tmp, &t->image[face][hwlevel], sizeof(tmp));
if (texImage->TexFormat->TexelBytes > 4) {
const int log2TexelBytes = (3 + (texImage->TexFormat->TexelBytes >> 4));
tex.format = RADEON_TXFORMAT_I8; /* any 1-byte texel format */
tex.pitch = MAX2((texImage->Width * texImage->TexFormat->TexelBytes) / 64, 1);
const int log2TexelBytes =
(3 + (texImage->TexFormat->TexelBytes >> 4));
tex.format = RADEON_TXFORMAT_I8; /* any 1-byte texel format */
tex.pitch =
MAX2((texImage->Width * texImage->TexFormat->TexelBytes) /
64, 1);
tex.height = imageHeight;
tex.width = imageWidth << log2TexelBytes;
tex.offset += (tmp.x << log2TexelBytes) & ~1023;
@@ -410,7 +409,7 @@ static void uploadSubImage( r300ContextPtr rmesa, r300TexObjPtr t,
/* use multi-byte upload scheme */
tex.height = imageHeight;
tex.width = imageWidth;
switch(texImage->TexFormat->TexelBytes) {
switch (texImage->TexFormat->TexelBytes) {
case 1:
tex.format = RADEON_TXFORMAT_I8;
break;
@@ -421,23 +420,28 @@ static void uploadSubImage( r300ContextPtr rmesa, r300TexObjPtr t,
tex.format = RADEON_TXFORMAT_ARGB8888;
break;
}
tex.pitch = MAX2((texImage->Width * texImage->TexFormat->TexelBytes) / 64, 1);
tex.pitch =
MAX2((texImage->Width * texImage->TexFormat->TexelBytes) /
64, 1);
tex.offset += tmp.x & ~1023;
tmp.x = tmp.x % 1024;
if (t->tile_bits & R300_TXO_MICRO_TILE) {
/* need something like "tiled coordinates" ? */
tmp.y = tmp.x / (tex.pitch * 128) * 2;
tmp.x = tmp.x % (tex.pitch * 128) / 2 / texImage->TexFormat->TexelBytes;
tmp.x =
tmp.x % (tex.pitch * 128) / 2 /
texImage->TexFormat->TexelBytes;
tex.pitch |= RADEON_DST_TILE_MICRO >> 22;
} else {
tmp.x = tmp.x >> (texImage->TexFormat->TexelBytes >> 1);
}
#if 1
if ((t->tile_bits & R300_TXO_MACRO_TILE) &&
(texImage->Width * texImage->TexFormat->TexelBytes >= 256) &&
((!(t->tile_bits & R300_TXO_MICRO_TILE) && (texImage->Height >= 8)) ||
(texImage->Height >= 16))) {
(texImage->Width * texImage->TexFormat->TexelBytes >= 256)
&& ((!(t->tile_bits & R300_TXO_MICRO_TILE)
&& (texImage->Height >= 8))
|| (texImage->Height >= 16))) {
/* weird: R200 disables macro tiling if mip width is smaller than 256 bytes,
OR if height is smaller than 8 automatically, but if micro tiling is active
the limit is height 16 instead ? */
@@ -451,41 +455,43 @@ static void uploadSubImage( r300ContextPtr rmesa, r300TexObjPtr t,
/* set tex.height to 1/4 since 1 "macropixel" (dxt-block)
has 4 real pixels. Needed so the kernel module reads
the right amount of data. */
tex.format = RADEON_TXFORMAT_I8; /* any 1-byte texel format */
tex.format = RADEON_TXFORMAT_I8; /* any 1-byte texel format */
tex.pitch = (R300_BLIT_WIDTH_BYTES / 64);
tex.height = (imageHeight + 3) / 4;
tex.width = (imageWidth + 3) / 4;
if ((t->format & R300_TX_FORMAT_DXT1) == R300_TX_FORMAT_DXT1)
{
if ((t->format & R300_TX_FORMAT_DXT1) == R300_TX_FORMAT_DXT1) {
tex.width *= 8;
} else {
tex.width *= 16;
}
}
LOCK_HARDWARE( &rmesa->radeon );
LOCK_HARDWARE(&rmesa->radeon);
do {
ret = drmCommandWriteRead( rmesa->radeon.dri.fd, DRM_RADEON_TEXTURE,
&tex, sizeof(drm_radeon_texture_t) );
ret =
drmCommandWriteRead(rmesa->radeon.dri.fd,
DRM_RADEON_TEXTURE, &tex,
sizeof(drm_radeon_texture_t));
if (ret) {
if (RADEON_DEBUG & DEBUG_IOCTL)
fprintf(stderr, "DRM_RADEON_TEXTURE: again!\n");
usleep(1);
if (RADEON_DEBUG & DEBUG_IOCTL)
fprintf(stderr,
"DRM_RADEON_TEXTURE: again!\n");
usleep(1);
}
} while ( ret == -EAGAIN );
} while (ret == -EAGAIN);
UNLOCK_HARDWARE( &rmesa->radeon );
UNLOCK_HARDWARE(&rmesa->radeon);
if ( ret ) {
fprintf( stderr, "DRM_RADEON_TEXTURE: return = %d\n", ret );
fprintf( stderr, " offset=0x%08x\n",
offset );
fprintf( stderr, " image width=%d height=%d\n",
imageWidth, imageHeight );
fprintf( stderr, " blit width=%d height=%d data=%p\n",
t->image[face][hwlevel].width, t->image[face][hwlevel].height,
t->image[face][hwlevel].data );
exit( 1 );
if (ret) {
fprintf(stderr, "DRM_RADEON_TEXTURE: return = %d\n", ret);
fprintf(stderr, " offset=0x%08x\n", offset);
fprintf(stderr, " image width=%d height=%d\n",
imageWidth, imageHeight);
fprintf(stderr, " blit width=%d height=%d data=%p\n",
t->image[face][hwlevel].width,
t->image[face][hwlevel].height,
t->image[face][hwlevel].data);
_mesa_exit(-1);
}
}
@@ -557,9 +563,10 @@ int r300UploadTexImages(r300ContextPtr rmesa, r300TexObjPtr t, GLuint face)
dirty_images[face] & (1 <<
(i + t->base.firstLevel))) !=
0) {
uploadSubImage(rmesa, t, i, 0, 0,
t->image[face][i].width,
t->image[face][i].height, face);
r300UploadSubImage(rmesa, t, i, 0, 0,
t->image[face][i].width,
t->image[face][i].height,
face);
}
}
t->base.dirty_images[face] = 0;

View File

@@ -27,9 +27,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
/*
* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
/**
* \file
*
* \author Keith Whitwell <keith@tungstengraphics.com>
*
* \todo Enable R300 texture tiling code?
*/
#include "glheader.h"
@@ -46,7 +49,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r300_tex.h"
#include "r300_reg.h"
#define VALID_FORMAT(f) ( ((f) <= MESA_FORMAT_RGBA_DXT5 \
|| ((f) >= MESA_FORMAT_RGBA_FLOAT32 && \
(f) <= MESA_FORMAT_INTENSITY_FLOAT16)) \
@@ -55,100 +57,103 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define _ASSIGN(entry, format) \
[ MESA_FORMAT_ ## entry ] = { format, 0, 1}
/*
* 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
*/
static const struct {
GLuint format, filter, flag;
} tx_table_be[] = {
/*
* 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(Z, Y, X, W, W8Z8Y8X8)),
_ASSIGN(RGBA8888_REV, R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8)),
_ASSIGN(ARGB8888, R300_EASY_TX_FORMAT(W, Z, Y, X, 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(X, Y, Z, W, W1Z5Y5X5)),
_ASSIGN(ARGB1555_REV, R300_EASY_TX_FORMAT(X, Y, Z, W, W1Z5Y5X5)),
_ASSIGN(AL88, R300_EASY_TX_FORMAT(X, X, X, Y, Y8X8)),
_ASSIGN(AL88_REV, R300_EASY_TX_FORMAT(X, X, X, Y, 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),
_ASSIGN(RGB_DXT1, R300_EASY_TX_FORMAT(X, Y, Z, ONE, DXT1)),
_ASSIGN(RGBA_DXT1, R300_EASY_TX_FORMAT(X, Y, Z, W, DXT1)),
_ASSIGN(RGBA_DXT3, R300_EASY_TX_FORMAT(X, Y, Z, W, DXT3)),
_ASSIGN(RGBA_DXT5, R300_EASY_TX_FORMAT(Y, Z, W, X, DXT5)),
_ASSIGN(RGBA_FLOAT32, R300_EASY_TX_FORMAT(Z, Y, X, W, FL_R32G32B32A32)),
_ASSIGN(RGBA_FLOAT16, R300_EASY_TX_FORMAT(Z, Y, X, W, FL_R16G16B16A16)),
_ASSIGN(RGB_FLOAT32, 0xffffffff),
_ASSIGN(RGB_FLOAT16, 0xffffffff),
_ASSIGN(ALPHA_FLOAT32, R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, FL_I32)),
_ASSIGN(ALPHA_FLOAT16, R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, FL_I16)),
_ASSIGN(LUMINANCE_FLOAT32, R300_EASY_TX_FORMAT(X, X, X, ONE, FL_I32)),
_ASSIGN(LUMINANCE_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, ONE, FL_I16)),
_ASSIGN(LUMINANCE_ALPHA_FLOAT32, R300_EASY_TX_FORMAT(X, X, X, Y, FL_I32A32)),
_ASSIGN(LUMINANCE_ALPHA_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, Y, FL_I16A16)),
_ASSIGN(INTENSITY_FLOAT32, R300_EASY_TX_FORMAT(X, X, X, X, FL_I32)),
_ASSIGN(INTENSITY_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, X, FL_I16)),
};
/* *INDENT-OFF* */
_ASSIGN(RGBA8888, R300_EASY_TX_FORMAT(Z, Y, X, W, W8Z8Y8X8)),
_ASSIGN(RGBA8888_REV, R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8)),
_ASSIGN(ARGB8888, R300_EASY_TX_FORMAT(W, Z, Y, X, 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(X, Y, Z, W, W1Z5Y5X5)),
_ASSIGN(ARGB1555_REV, R300_EASY_TX_FORMAT(X, Y, Z, W, W1Z5Y5X5)),
_ASSIGN(AL88, R300_EASY_TX_FORMAT(X, X, X, Y, Y8X8)),
_ASSIGN(AL88_REV, R300_EASY_TX_FORMAT(X, X, X, Y, 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),
_ASSIGN(RGB_DXT1, R300_EASY_TX_FORMAT(X, Y, Z, ONE, DXT1)),
_ASSIGN(RGBA_DXT1, R300_EASY_TX_FORMAT(X, Y, Z, W, DXT1)),
_ASSIGN(RGBA_DXT3, R300_EASY_TX_FORMAT(X, Y, Z, W, DXT3)),
_ASSIGN(RGBA_DXT5, R300_EASY_TX_FORMAT(Y, Z, W, X, DXT5)),
_ASSIGN(RGBA_FLOAT32, R300_EASY_TX_FORMAT(Z, Y, X, W, FL_R32G32B32A32)),
_ASSIGN(RGBA_FLOAT16, R300_EASY_TX_FORMAT(Z, Y, X, W, FL_R16G16B16A16)),
_ASSIGN(RGB_FLOAT32, 0xffffffff),
_ASSIGN(RGB_FLOAT16, 0xffffffff),
_ASSIGN(ALPHA_FLOAT32, R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, FL_I32)),
_ASSIGN(ALPHA_FLOAT16, R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, FL_I16)),
_ASSIGN(LUMINANCE_FLOAT32, R300_EASY_TX_FORMAT(X, X, X, ONE, FL_I32)),
_ASSIGN(LUMINANCE_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, ONE, FL_I16)),
_ASSIGN(LUMINANCE_ALPHA_FLOAT32, R300_EASY_TX_FORMAT(X, X, X, Y, FL_I32A32)),
_ASSIGN(LUMINANCE_ALPHA_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, Y, FL_I16A16)),
_ASSIGN(INTENSITY_FLOAT32, R300_EASY_TX_FORMAT(X, X, X, X, FL_I32)),
_ASSIGN(INTENSITY_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, X, FL_I16)),
/* *INDENT-ON* */
};
static const struct {
GLuint format, filter, flag;
} tx_table_le[] = {
_ASSIGN(RGBA8888, R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8)),
_ASSIGN(RGBA8888_REV, R300_EASY_TX_FORMAT(Z, Y, X, W, W8Z8Y8X8)),
_ASSIGN(ARGB8888, R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8)),
_ASSIGN(ARGB8888_REV, R300_EASY_TX_FORMAT(W, Z, Y, X, 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(X, Y, Z, W, W1Z5Y5X5)),
_ASSIGN(ARGB1555_REV, R300_EASY_TX_FORMAT(X, Y, Z, W, W1Z5Y5X5)),
_ASSIGN(AL88, R300_EASY_TX_FORMAT(X, X, X, Y, Y8X8)),
_ASSIGN(AL88_REV, R300_EASY_TX_FORMAT(X, X, X, Y, 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),
_ASSIGN(RGB_DXT1, R300_EASY_TX_FORMAT(X, Y, Z, ONE, DXT1)),
_ASSIGN(RGBA_DXT1, R300_EASY_TX_FORMAT(X, Y, Z, W, DXT1)),
_ASSIGN(RGBA_DXT3, R300_EASY_TX_FORMAT(X, Y, Z, W, DXT3)),
_ASSIGN(RGBA_DXT5, R300_EASY_TX_FORMAT(Y, Z, W, X, DXT5)),
_ASSIGN(RGBA_FLOAT32, R300_EASY_TX_FORMAT(Z, Y, X, W, FL_R32G32B32A32)),
_ASSIGN(RGBA_FLOAT16, R300_EASY_TX_FORMAT(Z, Y, X, W, FL_R16G16B16A16)),
_ASSIGN(RGB_FLOAT32, 0xffffffff),
_ASSIGN(RGB_FLOAT16, 0xffffffff),
_ASSIGN(ALPHA_FLOAT32, R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, FL_I32)),
_ASSIGN(ALPHA_FLOAT16, R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, FL_I16)),
_ASSIGN(LUMINANCE_FLOAT32, R300_EASY_TX_FORMAT(X, X, X, ONE, FL_I32)),
_ASSIGN(LUMINANCE_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, ONE, FL_I16)),
_ASSIGN(LUMINANCE_ALPHA_FLOAT32, R300_EASY_TX_FORMAT(X, X, X, Y, FL_I32A32)),
_ASSIGN(LUMINANCE_ALPHA_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, Y, FL_I16A16)),
_ASSIGN(INTENSITY_FLOAT32, R300_EASY_TX_FORMAT(X, X, X, X, FL_I32)),
_ASSIGN(INTENSITY_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, X, FL_I16)),
};
/* *INDENT-OFF* */
_ASSIGN(RGBA8888, R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8)),
_ASSIGN(RGBA8888_REV, R300_EASY_TX_FORMAT(Z, Y, X, W, W8Z8Y8X8)),
_ASSIGN(ARGB8888, R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8)),
_ASSIGN(ARGB8888_REV, R300_EASY_TX_FORMAT(W, Z, Y, X, 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(X, Y, Z, W, W1Z5Y5X5)),
_ASSIGN(ARGB1555_REV, R300_EASY_TX_FORMAT(X, Y, Z, W, W1Z5Y5X5)),
_ASSIGN(AL88, R300_EASY_TX_FORMAT(X, X, X, Y, Y8X8)),
_ASSIGN(AL88_REV, R300_EASY_TX_FORMAT(X, X, X, Y, 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),
_ASSIGN(RGB_DXT1, R300_EASY_TX_FORMAT(X, Y, Z, ONE, DXT1)),
_ASSIGN(RGBA_DXT1, R300_EASY_TX_FORMAT(X, Y, Z, W, DXT1)),
_ASSIGN(RGBA_DXT3, R300_EASY_TX_FORMAT(X, Y, Z, W, DXT3)),
_ASSIGN(RGBA_DXT5, R300_EASY_TX_FORMAT(Y, Z, W, X, DXT5)),
_ASSIGN(RGBA_FLOAT32, R300_EASY_TX_FORMAT(Z, Y, X, W, FL_R32G32B32A32)),
_ASSIGN(RGBA_FLOAT16, R300_EASY_TX_FORMAT(Z, Y, X, W, FL_R16G16B16A16)),
_ASSIGN(RGB_FLOAT32, 0xffffffff),
_ASSIGN(RGB_FLOAT16, 0xffffffff),
_ASSIGN(ALPHA_FLOAT32, R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, FL_I32)),
_ASSIGN(ALPHA_FLOAT16, R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, FL_I16)),
_ASSIGN(LUMINANCE_FLOAT32, R300_EASY_TX_FORMAT(X, X, X, ONE, FL_I32)),
_ASSIGN(LUMINANCE_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, ONE, FL_I16)),
_ASSIGN(LUMINANCE_ALPHA_FLOAT32, R300_EASY_TX_FORMAT(X, X, X, Y, FL_I32A32)),
_ASSIGN(LUMINANCE_ALPHA_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, Y, FL_I16A16)),
_ASSIGN(INTENSITY_FLOAT32, R300_EASY_TX_FORMAT(X, X, X, X, FL_I32)),
_ASSIGN(INTENSITY_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, X, FL_I16)),
/* *INDENT-ON* */
};
#undef _ASSIGN
/**
* This function computes the number of bytes of storage needed for
* the given texture object (all mipmap levels, all cube faces).
@@ -176,14 +181,18 @@ static void r300SetTexImages(r300ContextPtr rmesa,
if (VALID_FORMAT(baseImage->TexFormat->MesaFormat)) {
if (_mesa_little_endian()) {
t->format =
tx_table_le[baseImage->TexFormat->MesaFormat].format;
tx_table_le[baseImage->TexFormat->MesaFormat].
format;
t->filter |=
tx_table_le[baseImage->TexFormat->MesaFormat].filter;
tx_table_le[baseImage->TexFormat->MesaFormat].
filter;
} else {
t->format =
tx_table_be[baseImage->TexFormat->MesaFormat].format;
tx_table_be[baseImage->TexFormat->MesaFormat].
format;
t->filter |=
tx_table_be[baseImage->TexFormat->MesaFormat].filter;
tx_table_be[baseImage->TexFormat->MesaFormat].
filter;
}
} else {
_mesa_problem(NULL, "unexpected texture format in %s",
@@ -213,18 +222,21 @@ static void r300SetTexImages(r300ContextPtr rmesa,
t->tile_bits = 0;
/* figure out if this texture is suitable for tiling. */
#if 0 /* Disabled for now */
#if 0 /* Disabled for now */
if (texelBytes) {
if (rmesa->texmicrotile && (tObj->Target != GL_TEXTURE_RECTANGLE_NV) &&
/* texrect might be able to use micro tiling too in theory? */
(baseImage->Height > 1)) {
if ((tObj->Target != GL_TEXTURE_RECTANGLE_NV) &&
/* texrect might be able to use micro tiling too in theory? */
(baseImage->Height > 1)) {
/* allow 32 (bytes) x 1 mip (which will use two times the space
the non-tiled version would use) max if base texture is large enough */
if ((numLevels == 1) ||
(((baseImage->Width * texelBytes / baseImage->Height) <= 32) &&
(baseImage->Width * texelBytes > 64)) ||
((baseImage->Width * texelBytes / baseImage->Height) <= 16)) {
(((baseImage->Width * texelBytes /
baseImage->Height) <= 32)
&& (baseImage->Width * texelBytes > 64))
||
((baseImage->Width * texelBytes /
baseImage->Height) <= 16)) {
t->tile_bits |= R300_TXO_MICRO_TILE;
}
}
@@ -246,9 +258,10 @@ static void r300SetTexImages(r300ContextPtr rmesa,
/* find image size in bytes */
if (texImage->IsCompressed) {
if ((t->format & R300_TX_FORMAT_DXT1) == R300_TX_FORMAT_DXT1) {
if ((t->format & R300_TX_FORMAT_DXT1) ==
R300_TX_FORMAT_DXT1) {
// fprintf(stderr,"DXT 1 %d %08X\n", texImage->Width, t->format);
if ((texImage->Width + 3) < 8) /* width one block */
if ((texImage->Width + 3) < 8) /* width one block */
size = texImage->CompressedSize * 4;
else if ((texImage->Width + 3) < 16)
size = texImage->CompressedSize * 2;
@@ -256,7 +269,8 @@ static void r300SetTexImages(r300ContextPtr rmesa,
size = texImage->CompressedSize;
} else {
/* DXT3/5, 16 bytes per block */
WARN_ONCE("DXT 3/5 suffers from multitexturing problems!\n");
WARN_ONCE
("DXT 3/5 suffers from multitexturing problems!\n");
// fprintf(stderr,"DXT 3/5 %d\n", texImage->Width);
if ((texImage->Width + 3) < 8)
size = texImage->CompressedSize * 2;
@@ -264,14 +278,18 @@ static void r300SetTexImages(r300ContextPtr rmesa,
size = texImage->CompressedSize;
}
} else if (tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
size = ((texImage->Width * texelBytes + 63) & ~63) * texImage->Height;
size =
((texImage->Width * texelBytes +
63) & ~63) * texImage->Height;
blitWidth = 64 / texelBytes;
} else if (t->tile_bits & R300_TXO_MICRO_TILE) {
/* tile pattern is 16 bytes x2. mipmaps stay 32 byte aligned,
though the actual offset may be different (if texture is less than
32 bytes width) to the untiled case */
though the actual offset may be different (if texture is less than
32 bytes width) to the untiled case */
int w = (texImage->Width * texelBytes * 2 + 31) & ~31;
size = (w * ((texImage->Height + 1) / 2)) * texImage->Depth;
size =
(w * ((texImage->Height + 1) / 2)) *
texImage->Depth;
blitWidth = MAX2(texImage->Width, 64 / texelBytes);
} else {
int w = (texImage->Width * texelBytes + 31) & ~31;
@@ -280,11 +298,12 @@ static void r300SetTexImages(r300ContextPtr rmesa,
}
assert(size > 0);
if(0)
if (RADEON_DEBUG & DEBUG_TEXTURE)
fprintf(stderr, "w=%d h=%d d=%d tb=%d intFormat=%d\n",
texImage->Width, texImage->Height,
texImage->Depth, texImage->TexFormat->TexelBytes,
texImage->InternalFormat);
texImage->Width, texImage->Height,
texImage->Depth,
texImage->TexFormat->TexelBytes,
texImage->InternalFormat);
/* Align to 32-byte offset. It is faster to do this unconditionally
* (no branch penalty).
@@ -296,22 +315,25 @@ static void r300SetTexImages(r300ContextPtr rmesa,
/* fix x and y coords up later together with offset */
t->image[0][i].x = curOffset;
t->image[0][i].y = 0;
t->image[0][i].width = MIN2(size / texelBytes, blitWidth);
t->image[0][i].height = (size / texelBytes) / t->image[0][i].width;
t->image[0][i].width =
MIN2(size / texelBytes, blitWidth);
t->image[0][i].height =
(size / texelBytes) / t->image[0][i].width;
} else {
t->image[0][i].x = curOffset % R300_BLIT_WIDTH_BYTES;
t->image[0][i].y = curOffset / R300_BLIT_WIDTH_BYTES;
t->image[0][i].width = MIN2(size, R300_BLIT_WIDTH_BYTES);
t->image[0][i].width =
MIN2(size, R300_BLIT_WIDTH_BYTES);
t->image[0][i].height = size / t->image[0][i].width;
}
if (0)
if (RADEON_DEBUG & DEBUG_TEXTURE)
fprintf(stderr,
"level %d: %dx%d x=%d y=%d w=%d h=%d size=%d at %d\n",
i, texImage->Width, texImage->Height,
t->image[0][i].x, t->image[0][i].y,
t->image[0][i].width, t->image[0][i].height,
size, curOffset);
"level %d: %dx%d x=%d y=%d w=%d h=%d size=%d at %d\n",
i, texImage->Width, texImage->Height,
t->image[0][i].x, t->image[0][i].y,
t->image[0][i].width, t->image[0][i].height,
size, curOffset);
curOffset += size;
}
@@ -336,45 +358,17 @@ static void r300SetTexImages(r300ContextPtr rmesa,
t->base.totalSize *= 6; /* total texmem needed */
}
/* Hardware state:
*/
#if 0
t->format &= ~(R200_TXFORMAT_WIDTH_MASK |
R200_TXFORMAT_HEIGHT_MASK |
R200_TXFORMAT_CUBIC_MAP_ENABLE |
R200_TXFORMAT_F5_WIDTH_MASK |
R200_TXFORMAT_F5_HEIGHT_MASK);
t->format |= ((log2Width << R200_TXFORMAT_WIDTH_SHIFT) |
(log2Height << R200_TXFORMAT_HEIGHT_SHIFT));
#endif
#if 0
t->format_x &= ~(R200_DEPTH_LOG2_MASK | R200_TEXCOORD_MASK);
if (tObj->Target == GL_TEXTURE_3D) {
t->format_x |= (log2Depth << R200_DEPTH_LOG2_SHIFT);
t->format_x |= R200_TEXCOORD_VOLUME;
} else if (tObj->Target == GL_TEXTURE_CUBE_MAP) {
ASSERT(log2Width == log2Height);
t->format |= R300_TX_FORMAT_CUBIC_MAP;
t->format_x |= R200_TEXCOORD_CUBIC_ENV;
t->pp_cubic_faces = ((log2Width << R200_FACE_WIDTH_1_SHIFT) |
(log2Height << R200_FACE_HEIGHT_1_SHIFT) |
(log2Width << R200_FACE_WIDTH_2_SHIFT) |
(log2Height << R200_FACE_HEIGHT_2_SHIFT) |
(log2Width << R200_FACE_WIDTH_3_SHIFT) |
(log2Height << R200_FACE_HEIGHT_3_SHIFT) |
(log2Width << R200_FACE_WIDTH_4_SHIFT) |
(log2Height << R200_FACE_HEIGHT_4_SHIFT));
}
#endif
if (tObj->Target == GL_TEXTURE_CUBE_MAP) {
ASSERT(log2Width == log2Height);
t->format |= R300_TX_FORMAT_CUBIC_MAP;
}
t->size = (((tObj->Image[0][t->base.firstLevel]->Width - 1) << R300_TX_WIDTHMASK_SHIFT)
|((tObj->Image[0][t->base.firstLevel]->Height - 1) << R300_TX_HEIGHTMASK_SHIFT))
|((numLevels - 1) << R300_TX_MAX_MIP_LEVEL_SHIFT);
t->size =
(((tObj->Image[0][t->base.firstLevel]->Width -
1) << R300_TX_WIDTHMASK_SHIFT)
| ((tObj->Image[0][t->base.firstLevel]->Height - 1) <<
R300_TX_HEIGHTMASK_SHIFT))
| ((numLevels - 1) << R300_TX_MAX_MIP_LEVEL_SHIFT);
/* Only need to round to nearest 32 for textures, but the blitter
* requires 64-byte aligned pitches, and we may/may not need the
@@ -383,15 +377,15 @@ static void r300SetTexImages(r300ContextPtr rmesa,
if (baseImage->IsCompressed) {
t->pitch =
(tObj->Image[0][t->base.firstLevel]->Width + 63) & ~(63);
}
else if (tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
} else if (tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
unsigned int align = blitWidth - 1;
t->pitch = ((tObj->Image[0][t->base.firstLevel]->Width *
texelBytes) + 63) & ~(63);
texelBytes) + 63) & ~(63);
t->size |= R300_TX_SIZE_TXPITCH_EN;
t->pitch_reg = (((tObj->Image[0][t->base.firstLevel]->Width) + align) & ~align) - 1;
}
else {
t->pitch_reg =
(((tObj->Image[0][t->base.firstLevel]->Width) +
align) & ~align) - 1;
} else {
t->pitch =
((tObj->Image[0][t->base.firstLevel]->Width *
texelBytes) + 63) & ~(63);
@@ -402,12 +396,11 @@ static void r300SetTexImages(r300ContextPtr rmesa,
/* FYI: r300UploadTexImages( rmesa, t ) used to be called here */
}
/* ================================================================
* Texture unit state management
*/
static GLboolean enable_tex_2d(GLcontext * ctx, int unit)
static GLboolean r300EnableTexture2D(GLcontext * ctx, int unit)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
@@ -427,26 +420,16 @@ static GLboolean enable_tex_2d(GLcontext * ctx, int unit)
return GL_TRUE;
}
#if ENABLE_HW_3D_TEXTURE
static GLboolean enable_tex_3d(GLcontext * ctx, int unit)
static GLboolean r300EnableTexture3D(GLcontext * ctx, int unit)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
struct gl_texture_object *tObj = texUnit->_Current;
r300TexObjPtr t = (r300TexObjPtr) tObj->DriverData;
/* Need to load the 3d 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_3D);
/* R100 & R200 do not support mipmaps for 3D textures.
*/
/* r300 does not support mipmaps for 3D textures. */
if ((tObj->MinFilter != GL_NEAREST) && (tObj->MinFilter != GL_LINEAR)) {
return GL_FALSE;
}
@@ -461,9 +444,8 @@ static GLboolean enable_tex_3d(GLcontext * ctx, int unit)
return GL_TRUE;
}
#endif
static GLboolean enable_tex_cube(GLcontext * ctx, int unit)
static GLboolean r300EnableTextureCube(GLcontext * ctx, int unit)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
@@ -471,15 +453,6 @@ static GLboolean enable_tex_cube(GLcontext * ctx, int unit)
r300TexObjPtr t = (r300TexObjPtr) tObj->DriverData;
GLuint face;
/* 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;
for (face = 0; face < 6; face++)
t->base.dirty_images[face] = ~0;
}
#endif
ASSERT(tObj->Target == GL_TEXTURE_CUBE_MAP);
if (t->base.dirty_images[0] || t->base.dirty_images[1] ||
@@ -508,7 +481,7 @@ static GLboolean enable_tex_cube(GLcontext * ctx, int unit)
return GL_TRUE;
}
static GLboolean enable_tex_rect(GLcontext * ctx, int unit)
static GLboolean r300EnableTextureRect(GLcontext * ctx, int unit)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
@@ -528,7 +501,7 @@ static GLboolean enable_tex_rect(GLcontext * ctx, int unit)
return GL_TRUE;
}
static GLboolean update_tex_common(GLcontext * ctx, int unit)
static GLboolean r300UpdateTexture(GLcontext * ctx, int unit)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
@@ -566,39 +539,33 @@ static GLboolean r300UpdateTextureUnit(GLcontext * ctx, int unit)
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
if (texUnit->_ReallyEnabled & (TEXTURE_RECT_BIT)) {
return (enable_tex_rect(ctx, unit) &&
update_tex_common(ctx, unit));
return (r300EnableTextureRect(ctx, unit) &&
r300UpdateTexture(ctx, unit));
} else if (texUnit->_ReallyEnabled & (TEXTURE_1D_BIT | TEXTURE_2D_BIT)) {
return (enable_tex_2d(ctx, unit) &&
update_tex_common(ctx, unit));
}
#if ENABLE_HW_3D_TEXTURE
else if (texUnit->_ReallyEnabled & (TEXTURE_3D_BIT)) {
return (enable_tex_3d(ctx, unit) &&
update_tex_common(ctx, unit));
}
#endif
else if (texUnit->_ReallyEnabled & (TEXTURE_CUBE_BIT)) {
return (enable_tex_cube(ctx, unit) &&
update_tex_common(ctx, unit));
return (r300EnableTexture2D(ctx, unit) &&
r300UpdateTexture(ctx, unit));
} else if (texUnit->_ReallyEnabled & (TEXTURE_3D_BIT)) {
return (r300EnableTexture3D(ctx, unit) &&
r300UpdateTexture(ctx, unit));
} else if (texUnit->_ReallyEnabled & (TEXTURE_CUBE_BIT)) {
return (r300EnableTextureCube(ctx, unit) &&
r300UpdateTexture(ctx, unit));
} else if (texUnit->_ReallyEnabled) {
return GL_FALSE;
} else {
return GL_TRUE;
}
}
}
void r300UpdateTextureState(GLcontext * ctx)
{
GLboolean ok;
int i;
ok = (r300UpdateTextureUnit(ctx, 0) &&
r300UpdateTextureUnit(ctx, 1) &&
r300UpdateTextureUnit(ctx, 2) &&
r300UpdateTextureUnit(ctx, 3) &&
r300UpdateTextureUnit(ctx, 4) &&
r300UpdateTextureUnit(ctx, 5) &&
r300UpdateTextureUnit(ctx, 6) &&
r300UpdateTextureUnit(ctx, 7)
);
for (i = 0; i < 8; i++) {
if (!r300UpdateTextureUnit(ctx, i)) {
_mesa_warning(ctx,
"failed to update texture state for unit %d.\n",
i);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,14 +1,12 @@
#ifndef __VERTEX_SHADER_H__
#define __VERTEX_SHADER_H__
#ifndef __R300_VERTPROG_H_
#define __R300_VERTPROG_H_
#include "r300_reg.h"
typedef struct {
CARD32 op;
CARD32 src1;
CARD32 src2;
CARD32 src3;
} VERTEX_SHADER_INSTRUCTION;
GLuint op;
GLuint src[3];
} VERTEX_SHADER_INSTRUCTION;
#define VSF_FLAG_X 1
#define VSF_FLAG_Y 2
@@ -22,8 +20,7 @@ typedef struct {
#define VSF_OUT_CLASS_ADDR 1
#define VSF_OUT_CLASS_RESULT 2
/* first CARD32 of an instruction */
/* first DWORD of an instruction */
/* possible operations:
DOT, MUL, ADD, MAD, FRC, MAX, MIN, SGE, SLT, EXP, LOG, LIT, POW, RCP, RSQ, EX2,
@@ -38,7 +35,7 @@ typedef struct {
#define EASY_VSF_OP(op, out_reg_index, out_reg_fields, class) \
MAKE_VSF_OP(R300_VPI_OUT_OP_##op, out_reg_index, VSF_FLAG_##out_reg_fields, VSF_OUT_CLASS_##class) \
/* according to Nikolai, the subsequent 3 CARD32 are sources, use same define for each */
/* according to Nikolai, the subsequent 3 DWORDs are sources, use same define for each */
#define VSF_IN_CLASS_TMP 0
#define VSF_IN_CLASS_ATTR 1
@@ -59,7 +56,7 @@ typedef struct {
| ((comp_z)<<R300_VPI_IN_Z_SHIFT) \
| ((comp_w)<<R300_VPI_IN_W_SHIFT) \
| ((negate)<<25) | ((class)))
#define EASY_VSF_SOURCE(in_reg_index, comp_x, comp_y, comp_z, comp_w, class, negate) \
MAKE_VSF_SOURCE(in_reg_index, \
VSF_IN_COMPONENT_##comp_x, \
@@ -71,8 +68,8 @@ typedef struct {
/* special sources: */
/* (1.0,1.0,1.0,1.0) vector (ATTR, plain ) */
#define VSF_ATTR_UNITY(reg) EASY_VSF_SOURCE(reg, ONE, ONE, ONE, ONE, ATTR, NONE)
#define VSF_UNITY(reg) EASY_VSF_SOURCE(reg, ONE, ONE, ONE, ONE, NONE, NONE)
#define VSF_ATTR_UNITY(reg) EASY_VSF_SOURCE(reg, ONE, ONE, ONE, ONE, ATTR, NONE)
#define VSF_UNITY(reg) EASY_VSF_SOURCE(reg, ONE, ONE, ONE, ONE, NONE, NONE)
/* contents of unmodified register */
#define VSF_REG(reg) EASY_VSF_SOURCE(reg, X, Y, Z, W, ATTR, NONE)

View File

@@ -90,9 +90,15 @@ static const GLubyte *radeonGetString(GLcontext * ctx, GLenum name)
offset = driGetRendererString(buffer, chipname, DRIVER_DATE,
agp_mode);
if (IS_R300_CLASS(radeon->radeonScreen)) {
sprintf(&buffer[offset], " %sTCL",
(radeon->radeonScreen->chip_flags & RADEON_CHIPSET_TCL)
? "" : "NO-");
} else {
sprintf(&buffer[offset], " %sTCL",
!(radeon->TclFallback & RADEON_TCL_FALLBACK_TCL_DISABLE)
? "" : "NO-");
}
return (GLubyte *) buffer;
}
@@ -283,7 +289,6 @@ GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv,
radeon->dri.drawable = driDrawPriv;
radeonSetCliprects(radeon);
r300UpdateWindow(radeon->glCtx);
r300UpdateViewportOffset(radeon->glCtx);
}
@@ -293,12 +298,9 @@ GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv,
(GLframebuffer *) driReadPriv->
driverPrivate);
if (!radeon->glCtx->Viewport.Width) {
_mesa_set_viewport(radeon->glCtx, 0, 0,
driDrawPriv->w, driDrawPriv->h);
}
_mesa_update_state(radeon->glCtx);
radeonUpdatePageFlipping(radeon);
} else {
if (RADEON_DEBUG & DEBUG_DRI)
fprintf(stderr, "%s ctx is null\n", __FUNCTION__);

View File

@@ -1,10 +1,15 @@
/*
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
VA Linux Systems Inc., Fremont, California.
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
initial release of the Radeon 8500 driver under the XFree86 license.
This notice must be preserved.
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
@@ -29,7 +34,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
* Gareth Hughes <gareth@valinux.com>
* Keith Whitwell <keith@tungstengraphics.com>
* Kevin E. Martin <martin@valinux.com>
* Nicolai Haehnle <prefect_@gmx.net>
*/
@@ -44,20 +51,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
struct radeon_context;
typedef struct radeon_context radeonContextRec;
typedef struct radeon_context* radeonContextPtr;
static __inline GLuint radeonPackColor(GLuint cpp,
GLubyte r, GLubyte g, GLubyte b, GLubyte a)
{
switch (cpp) {
case 2:
return PACK_COLOR_565(r, g, b);
case 4:
return PACK_COLOR_8888(a, r, g, b);
default:
return 0;
}
}
typedef struct radeon_context *radeonContextPtr;
#define TEX_0 0x1
#define TEX_1 0x2
@@ -69,17 +63,16 @@ static __inline GLuint radeonPackColor(GLuint cpp,
#define TEX_7 0x80
#define TEX_ALL 0xff
/* Rasterizing fallbacks */
/* See correponding strings in r200_swtcl.c */
#define RADEON_FALLBACK_TEXTURE 0x01
#define RADEON_FALLBACK_DRAW_BUFFER 0x02
#define RADEON_FALLBACK_STENCIL 0x04
#define RADEON_FALLBACK_RENDER_MODE 0x08
#define RADEON_FALLBACK_BLEND_EQ 0x10
#define RADEON_FALLBACK_BLEND_FUNC 0x20
#define RADEON_FALLBACK_DISABLE 0x40
#define RADEON_FALLBACK_BORDER_MODE 0x80
#define RADEON_FALLBACK_TEXTURE 0x0001
#define RADEON_FALLBACK_DRAW_BUFFER 0x0002
#define RADEON_FALLBACK_STENCIL 0x0004
#define RADEON_FALLBACK_RENDER_MODE 0x0008
#define RADEON_FALLBACK_BLEND_EQ 0x0010
#define RADEON_FALLBACK_BLEND_FUNC 0x0020
#define RADEON_FALLBACK_DISABLE 0x0040
#define RADEON_FALLBACK_BORDER_MODE 0x0080
#if R200_MERGED
extern void radeonFallback(GLcontext * ctx, GLuint bit, GLboolean mode);
@@ -116,19 +109,18 @@ extern void radeonTclFallback(GLcontext * ctx, GLuint bit, GLboolean mode);
#define TCL_FALLBACK( ctx, bit, mode ) ;
#endif
struct radeon_dri_mirror {
__DRIcontextPrivate *context; /* DRI context */
__DRIscreenPrivate *screen; /* DRI screen */
/**
* DRI drawable bound to this context for drawing.
*/
__DRIdrawablePrivate *drawable;
__DRIdrawablePrivate *drawable;
/**
* DRI drawable bound to this context for reading.
*/
__DRIdrawablePrivate *readable;
__DRIdrawablePrivate *readable;
drm_context_t hwContext;
drm_hw_lock_t *hwLock;
@@ -164,7 +156,7 @@ struct radeon_state {
* structure.
*/
struct radeon_context {
GLcontext *glCtx; /* Mesa context */
GLcontext *glCtx; /* Mesa context */
radeonScreenPtr radeonScreen; /* Screen private DRI data */
/* Fallback state */
@@ -200,7 +192,6 @@ struct radeon_context {
GLuint swap_count;
GLuint swap_missed_count;
/* Derived state */
struct radeon_state state;
@@ -215,7 +206,7 @@ extern void radeonSwapBuffers(__DRIdrawablePrivate * dPriv);
extern void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv,
int x, int y, int w, int h);
extern GLboolean radeonInitContext(radeonContextPtr radeon,
struct dd_function_table* functions,
struct dd_function_table *functions,
const __GLcontextModes * glVisual,
__DRIcontextPrivate * driContextPriv,
void *sharedContextPrivate);
@@ -252,4 +243,4 @@ extern int RADEON_DEBUG;
#define DEBUG_PIXEL 0x2000
#define DEBUG_MEMORY 0x4000
#endif /* __RADEON_CONTEXT_H__ */
#endif /* __RADEON_CONTEXT_H__ */

View File

@@ -1,10 +1,15 @@
/*
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
VA Linux Systems Inc., Fremont, California.
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
initial release of the Radeon 8500 driver under the XFree86 license.
This notice must be preserved.
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
@@ -29,9 +34,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
* Gareth Hughes <gareth@valinux.com>
* Keith Whitwell <keith@tungstengraphics.com>
* Kevin E. Martin <martin@valinux.com>
*/
#include <string.h>
#include "radeon_lock.h"
#include "radeon_ioctl.h"
@@ -50,54 +56,31 @@ int prevLockLine = 0;
/* Turn on/off page flipping according to the flags in the sarea:
*/
static void radeonUpdatePageFlipping(radeonContextPtr radeon)
void radeonUpdatePageFlipping(radeonContextPtr rmesa)
{
int use_back;
radeon->doPageFlip = radeon->sarea->pfState;
if (radeon->glCtx->WinSysDrawBuffer) {
driFlipRenderbuffers(radeon->glCtx->WinSysDrawBuffer, radeon->sarea->pfCurrentPage);
}
rmesa->doPageFlip = rmesa->sarea->pfState;
if (rmesa->glCtx->WinSysDrawBuffer) {
driFlipRenderbuffers(rmesa->glCtx->WinSysDrawBuffer,
rmesa->sarea->pfCurrentPage);
r300UpdateDrawBuffer(rmesa->glCtx);
}
use_back = (radeon->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT);
use_back ^= (radeon->sarea->pfCurrentPage == 1);
use_back = rmesa->glCtx->DrawBuffer ?
(rmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] ==
BUFFER_BIT_BACK_LEFT) : 1;
use_back ^= (rmesa->sarea->pfCurrentPage == 1);
if (use_back) {
radeon->state.color.drawOffset = radeon->radeonScreen->backOffset;
radeon->state.color.drawPitch = radeon->radeonScreen->backPitch;
rmesa->state.color.drawOffset =
rmesa->radeonScreen->backOffset;
rmesa->state.color.drawPitch = rmesa->radeonScreen->backPitch;
} else {
radeon->state.color.drawOffset = radeon->radeonScreen->frontOffset;
radeon->state.color.drawPitch = radeon->radeonScreen->frontPitch;
}
}
/**
* Called by radeonGetLock() after the lock has been obtained.
*/
static void r300RegainedLock(radeonContextPtr radeon)
{
int i;
__DRIdrawablePrivate *const drawable = radeon->dri.drawable;
r300ContextPtr r300 = (r300ContextPtr)radeon;
drm_radeon_sarea_t *sarea = radeon->sarea;
if ( radeon->lastStamp != drawable->lastStamp ) {
radeonUpdatePageFlipping(radeon);
radeonSetCliprects(radeon);
#if 1
r300UpdateViewportOffset( radeon->glCtx );
driUpdateFramebufferSize(radeon->glCtx, drawable);
#else
radeonUpdateScissor(radeon->glCtx);
#endif
}
if (sarea->ctx_owner != radeon->dri.hwContext) {
sarea->ctx_owner = radeon->dri.hwContext;
for (i = 0; i < r300->nr_heaps; i++) {
DRI_AGE_TEXTURES(r300->texture_heaps[i]);
}
rmesa->state.color.drawOffset =
rmesa->radeonScreen->frontOffset;
rmesa->state.color.drawPitch =
rmesa->radeonScreen->frontPitch;
}
}
@@ -109,15 +92,17 @@ static void r300RegainedLock(radeonContextPtr radeon)
* the hardware lock when it changes the window state, this routine will
* automatically be called after such a change.
*/
void radeonGetLock(radeonContextPtr radeon, GLuint flags)
void radeonGetLock(radeonContextPtr rmesa, GLuint flags)
{
__DRIdrawablePrivate *const drawable = radeon->dri.drawable;
__DRIdrawablePrivate *const readable = radeon->dri.readable;
__DRIscreenPrivate *sPriv = radeon->dri.screen;
assert (drawable != NULL);
__DRIdrawablePrivate *const drawable = rmesa->dri.drawable;
__DRIdrawablePrivate *const readable = rmesa->dri.readable;
__DRIscreenPrivate *sPriv = rmesa->dri.screen;
drm_radeon_sarea_t *sarea = rmesa->sarea;
r300ContextPtr r300 = (r300ContextPtr) rmesa;
drmGetLock(radeon->dri.fd, radeon->dri.hwContext, flags);
assert(drawable != NULL);
drmGetLock(rmesa->dri.fd, rmesa->dri.hwContext, flags);
/* The window might have moved, so we might need to get new clip
* rects.
@@ -127,13 +112,26 @@ void radeonGetLock(radeonContextPtr radeon, GLuint flags)
* Since the hardware state depends on having the latest drawable
* clip rects, all state checking must be done _after_ this call.
*/
DRI_VALIDATE_DRAWABLE_INFO( sPriv, drawable );
DRI_VALIDATE_DRAWABLE_INFO(sPriv, drawable);
if (drawable != readable) {
DRI_VALIDATE_DRAWABLE_INFO( sPriv, readable );
DRI_VALIDATE_DRAWABLE_INFO(sPriv, readable);
}
if (IS_R300_CLASS(radeon->radeonScreen))
r300RegainedLock(radeon);
radeon->lost_context = GL_TRUE;
if (rmesa->lastStamp != drawable->lastStamp) {
radeonUpdatePageFlipping(rmesa);
radeonSetCliprects(rmesa);
r300UpdateViewportOffset(rmesa->glCtx);
driUpdateFramebufferSize(rmesa->glCtx, drawable);
}
if (sarea->ctx_owner != rmesa->dri.hwContext) {
int i;
sarea->ctx_owner = rmesa->dri.hwContext;
for (i = 0; i < r300->nr_heaps; i++) {
DRI_AGE_TEXTURES(r300->texture_heaps[i]);
}
}
rmesa->lost_context = GL_TRUE;
}

View File

@@ -1,10 +1,15 @@
/*
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
VA Linux Systems Inc., Fremont, California.
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
initial release of the Radeon 8500 driver under the XFree86 license.
This notice must be preserved.
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
@@ -29,7 +34,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
* Gareth Hughes <gareth@valinux.com>
* Keith Whitwell <keith@tungstengraphics.com>
* Kevin E. Martin <martin@valinux.com>
*/
#ifndef __RADEON_LOCK_H__
@@ -40,7 +47,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#endif
#include "radeon_context.h"
extern void radeonGetLock(radeonContextPtr radeon, GLuint flags);
extern void radeonGetLock(radeonContextPtr rmesa, GLuint flags);
extern void radeonUpdatePageFlipping(radeonContextPtr rmesa);
/* Turn DEBUG_LOCKING on to find locking conflicts.
*/
@@ -64,11 +72,11 @@ extern int prevLockLine;
#define DEBUG_CHECK_LOCK() \
do { \
if ( prevLockFile ) { \
fprintf( stderr, \
if (prevLockFile) { \
fprintf(stderr, \
"LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \
prevLockFile, prevLockLine, __FILE__, __LINE__ ); \
exit( 1 ); \
prevLockFile, prevLockLine, __FILE__, __LINE__); \
exit(1); \
} \
} while (0)
@@ -88,38 +96,23 @@ extern int prevLockLine;
/* Lock the hardware and validate our state.
*/
#define LOCK_HARDWARE( radeon ) \
#define LOCK_HARDWARE( rmesa ) \
do { \
char __ret = 0; \
DEBUG_CHECK_LOCK(); \
DRM_CAS( (radeon)->dri.hwLock, (radeon)->dri.hwContext, \
(DRM_LOCK_HELD | (radeon)->dri.hwContext), __ret ); \
if ( __ret ) \
radeonGetLock( (radeon), 0 ); \
DRM_CAS((rmesa)->dri.hwLock, (rmesa)->dri.hwContext, \
(DRM_LOCK_HELD | (rmesa)->dri.hwContext), __ret); \
if (__ret) \
radeonGetLock((rmesa), 0); \
DEBUG_LOCK(); \
} while (0)
#if R200_MERGED
#define UNLOCK_HARDWARE( radeon ) \
#define UNLOCK_HARDWARE( rmesa ) \
do { \
DRM_UNLOCK( (radeon)->dri.fd, \
(radeon)->dri.hwLock, \
(radeon)->dri.hwContext ); \
DEBUG_RESET(); \
if (IS_R200_CLASS(radeon->radeonScreen)) { \
r200ContextPtr __r200 = (r200ContextPtr)(radeon); \
if (__r200->save_on_next_unlock) \
r200SaveHwState( __r200 ); \
__r200->save_on_next_unlock = GL_FALSE; \
} \
} while (0)
#else
#define UNLOCK_HARDWARE( radeon ) \
do { \
DRM_UNLOCK( (radeon)->dri.fd, \
(radeon)->dri.hwLock, \
(radeon)->dri.hwContext ); \
DRM_UNLOCK((rmesa)->dri.fd, \
(rmesa)->dri.hwLock, \
(rmesa)->dri.hwContext); \
DEBUG_RESET(); \
} while (0)
#endif
#endif /* __RADEON_LOCK_H__ */

View File

@@ -1,492 +0,0 @@
/*
* Copyright (C) 2005 Aapo Tahkola.
*
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
/*
* Authors:
* Aapo Tahkola <aet@rasterburn.org>
*/
#include <unistd.h>
#include "r300_context.h"
#include "r300_cmdbuf.h"
#include "r300_ioctl.h"
#include "radeon_mm.h"
#include "radeon_ioctl.h"
#ifdef USER_BUFFERS
static void resize_u_list(r300ContextPtr rmesa)
{
void *temp;
int nsize;
temp = rmesa->rmm->u_list;
nsize = rmesa->rmm->u_size * 2;
rmesa->rmm->u_list = _mesa_malloc(nsize * sizeof(*rmesa->rmm->u_list));
_mesa_memset(rmesa->rmm->u_list, 0, nsize * sizeof(*rmesa->rmm->u_list));
if (temp) {
r300FlushCmdBuf(rmesa, __FUNCTION__);
_mesa_memcpy(rmesa->rmm->u_list, temp, rmesa->rmm->u_size * sizeof(*rmesa->rmm->u_list));
_mesa_free(temp);
}
rmesa->rmm->u_size = nsize;
}
void radeon_mm_init(r300ContextPtr rmesa)
{
rmesa->rmm = malloc(sizeof(struct radeon_memory_manager));
memset(rmesa->rmm, 0, sizeof(struct radeon_memory_manager));
rmesa->rmm->u_size = 128;
resize_u_list(rmesa);
}
void radeon_mm_destroy(r300ContextPtr rmesa)
{
_mesa_free(rmesa->rmm->u_list);
rmesa->rmm->u_list = NULL;
_mesa_free(rmesa->rmm);
rmesa->rmm = NULL;
}
void *radeon_mm_ptr(r300ContextPtr rmesa, int id)
{
assert(id <= rmesa->rmm->u_last);
return rmesa->rmm->u_list[id].ptr;
}
int radeon_mm_find(r300ContextPtr rmesa, void *ptr)
{
int i;
for (i=1; i < rmesa->rmm->u_size+1; i++)
if(rmesa->rmm->u_list[i].ptr &&
ptr >= rmesa->rmm->u_list[i].ptr &&
ptr < rmesa->rmm->u_list[i].ptr + rmesa->rmm->u_list[i].size)
break;
if (i < rmesa->rmm->u_size + 1)
return i;
fprintf(stderr, "%p failed\n", ptr);
return 0;
}
//#define MM_DEBUG
int radeon_mm_alloc(r300ContextPtr rmesa, int alignment, int size)
{
drm_radeon_mem_alloc_t alloc;
int offset = 0, ret;
int i, free=-1;
int done_age;
drm_radeon_mem_free_t memfree;
int tries=0;
static int bytes_wasted=0, allocated=0;
if(size < 4096)
bytes_wasted += 4096 - size;
allocated += size;
#if 0
static int t=0;
if (t != time(NULL)) {
t = time(NULL);
fprintf(stderr, "slots used %d, wasted %d kb, allocated %d\n", rmesa->rmm->u_last, bytes_wasted/1024, allocated/1024);
}
#endif
memfree.region = RADEON_MEM_REGION_GART;
again:
done_age = radeonGetAge((radeonContextPtr)rmesa);
if (rmesa->rmm->u_last + 1 >= rmesa->rmm->u_size)
resize_u_list(rmesa);
for (i = rmesa->rmm->u_last + 1; i > 0; i --) {
if (rmesa->rmm->u_list[i].ptr == NULL) {
free = i;
continue;
}
if (rmesa->rmm->u_list[i].h_pending == 0 &&
rmesa->rmm->u_list[i].pending && rmesa->rmm->u_list[i].age <= done_age) {
memfree.region_offset = (char *)rmesa->rmm->u_list[i].ptr -
(char *)rmesa->radeon.radeonScreen->gartTextures.map;
ret = drmCommandWrite(rmesa->radeon.radeonScreen->driScreen->fd,
DRM_RADEON_FREE, &memfree, sizeof(memfree));
if (ret) {
fprintf(stderr, "Failed to free at %p\n", rmesa->rmm->u_list[i].ptr);
fprintf(stderr, "ret = %s\n", strerror(-ret));
exit(1);
} else {
#ifdef MM_DEBUG
fprintf(stderr, "really freed %d at age %x\n", i, radeonGetAge((radeonContextPtr)rmesa));
#endif
if (i == rmesa->rmm->u_last)
rmesa->rmm->u_last --;
if(rmesa->rmm->u_list[i].size < 4096)
bytes_wasted -= 4096 - rmesa->rmm->u_list[i].size;
allocated -= rmesa->rmm->u_list[i].size;
rmesa->rmm->u_list[i].pending = 0;
rmesa->rmm->u_list[i].ptr = NULL;
if (rmesa->rmm->u_list[i].fb) {
LOCK_HARDWARE(&(rmesa->radeon));
ret = mmFreeMem(rmesa->rmm->u_list[i].fb);
UNLOCK_HARDWARE(&(rmesa->radeon));
if (ret != 0)
fprintf(stderr, "failed to free!\n");
rmesa->rmm->u_list[i].fb = NULL;
}
rmesa->rmm->u_list[i].ref_count = 0;
free = i;
}
}
}
rmesa->rmm->u_head = i;
if (free == -1) {
WARN_ONCE("Ran out of slots!\n");
//usleep(100);
r300FlushCmdBuf(rmesa, __FUNCTION__);
tries++;
if(tries>100){
WARN_ONCE("Ran out of slots!\n");
exit(1);
}
goto again;
}
alloc.region = RADEON_MEM_REGION_GART;
alloc.alignment = alignment;
alloc.size = size;
alloc.region_offset = &offset;
ret = drmCommandWriteRead( rmesa->radeon.dri.fd, DRM_RADEON_ALLOC, &alloc, sizeof(alloc));
if (ret) {
#if 0
WARN_ONCE("Ran out of mem!\n");
r300FlushCmdBuf(rmesa, __FUNCTION__);
//usleep(100);
tries2++;
tries = 0;
if(tries2>100){
WARN_ONCE("Ran out of GART memory!\n");
exit(1);
}
goto again;
#else
WARN_ONCE("Ran out of GART memory (for %d)!\nPlease consider adjusting GARTSize option.\n", size);
return 0;
#endif
}
i = free;
if (i > rmesa->rmm->u_last)
rmesa->rmm->u_last = i;
rmesa->rmm->u_list[i].ptr = ((GLubyte *)rmesa->radeon.radeonScreen->gartTextures.map) + offset;
rmesa->rmm->u_list[i].size = size;
rmesa->rmm->u_list[i].age = 0;
rmesa->rmm->u_list[i].fb = NULL;
//fprintf(stderr, "alloc %p at id %d\n", rmesa->rmm->u_list[i].ptr, i);
#ifdef MM_DEBUG
fprintf(stderr, "allocated %d at age %x\n", i, radeonGetAge((radeonContextPtr)rmesa));
#endif
return i;
}
#include "r300_emit.h"
static void emit_lin_cp(r300ContextPtr rmesa, unsigned long dst, unsigned long src, unsigned long size)
{
int cmd_reserved = 0;
int cmd_written = 0;
drm_radeon_cmd_header_t *cmd = NULL;
int cp_size;
while (size > 0){
cp_size = size;
if(cp_size > /*8190*/4096)
cp_size = /*8190*/4096;
reg_start(0x146c,1);
e32(0x52cc32fb);
reg_start(0x15ac,1);
e32(src);
e32(cp_size);
reg_start(0x1704,0);
e32(0x0);
reg_start(0x1404,1);
e32(dst);
e32(cp_size);
reg_start(0x1700,0);
e32(0x0);
reg_start(0x1640,3);
e32(0x00000000);
e32(0x00001fff);
e32(0x00000000);
e32(0x00001fff);
start_packet3(RADEON_CP_PACKET3_UNK1B, 2);
e32(0 << 16 | 0);
e32(0 << 16 | 0);
e32(cp_size << 16 | 0x1);
dst += cp_size;
src += cp_size;
size -= cp_size;
}
reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
e32(R300_RB3D_DSTCACHE_UNKNOWN_0A);
reg_start(0x342c,0);
e32(0x00000005);
reg_start(0x1720,0);
e32(0x00010000);
}
void radeon_mm_use(r300ContextPtr rmesa, int id)
{
uint64_t ull;
#ifdef MM_DEBUG
fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id, radeonGetAge((radeonContextPtr)rmesa));
#endif
drm_r300_cmd_header_t *cmd;
assert(id <= rmesa->rmm->u_last);
if(id == 0)
return;
#if 0 /* FB VBOs. Needs further changes... */
rmesa->rmm->u_list[id].ref_count ++;
if (rmesa->rmm->u_list[id].ref_count > 100 && rmesa->rmm->u_list[id].fb == NULL &&
rmesa->rmm->u_list[id].size != RADEON_BUFFER_SIZE*16 /*&& rmesa->rmm->u_list[id].size > 40*/) {
driTexHeap *heap;
struct mem_block *mb;
LOCK_HARDWARE(&(rmesa->radeon));
heap = rmesa->texture_heaps[0];
mb = mmAllocMem(heap->memory_heap, rmesa->rmm->u_list[id].size, heap->alignmentShift, 0);
UNLOCK_HARDWARE(&(rmesa->radeon));
if (mb) {
rmesa->rmm->u_list[id].fb = mb;
emit_lin_cp(rmesa, rmesa->radeon.radeonScreen->texOffset[0] + rmesa->rmm->u_list[id].fb->ofs,
r300GartOffsetFromVirtual(rmesa, rmesa->rmm->u_list[id].ptr),
rmesa->rmm->u_list[id].size);
} else {
WARN_ONCE("Upload to fb failed, %d, %d\n", rmesa->rmm->u_list[id].size, id);
}
//fprintf(stderr, "Upload to fb! %d, %d\n", rmesa->rmm->u_list[id].ref_count, id);
}
/*if (rmesa->rmm->u_list[id].fb) {
emit_lin_cp(rmesa, rmesa->radeon.radeonScreen->texOffset[0] + rmesa->rmm->u_list[id].fb->ofs,
r300GartOffsetFromVirtual(rmesa, rmesa->rmm->u_list[id].ptr),
rmesa->rmm->u_list[id].size);
}*/
#endif
cmd = (drm_r300_cmd_header_t *)r300AllocCmdBuf(rmesa, 2 + sizeof(ull) / 4, __FUNCTION__);
cmd[0].scratch.cmd_type = R300_CMD_SCRATCH;
cmd[0].scratch.reg = RADEON_MM_SCRATCH;
cmd[0].scratch.n_bufs = 1;
cmd[0].scratch.flags = 0;
cmd ++;
ull = (uint64_t)(intptr_t)&rmesa->rmm->u_list[id].age;
_mesa_memcpy(cmd, &ull, sizeof(ull));
cmd += sizeof(ull) / 4;
cmd[0].u = /*id*/0;
LOCK_HARDWARE(&rmesa->radeon); /* Protect from DRM. */
rmesa->rmm->u_list[id].h_pending ++;
UNLOCK_HARDWARE(&rmesa->radeon);
}
unsigned long radeon_mm_offset(r300ContextPtr rmesa, int id)
{
unsigned long offset;
assert(id <= rmesa->rmm->u_last);
if (rmesa->rmm->u_list[id].fb) {
offset = rmesa->radeon.radeonScreen->texOffset[0] + rmesa->rmm->u_list[id].fb->ofs;
} else {
offset = (char *)rmesa->rmm->u_list[id].ptr -
(char *)rmesa->radeon.radeonScreen->gartTextures.map;
offset += rmesa->radeon.radeonScreen->gart_texture_offset;
}
return offset;
}
int radeon_mm_on_card(r300ContextPtr rmesa, int id)
{
assert(id <= rmesa->rmm->u_last);
if (rmesa->rmm->u_list[id].fb)
return GL_TRUE;
return GL_FALSE;
}
void *radeon_mm_map(r300ContextPtr rmesa, int id, int access)
{
#ifdef MM_DEBUG
fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id, radeonGetAge((radeonContextPtr)rmesa));
#endif
void *ptr;
int tries = 0;
assert(id <= rmesa->rmm->u_last);
rmesa->rmm->u_list[id].ref_count = 0;
if (rmesa->rmm->u_list[id].fb) {
WARN_ONCE("Mapping fb!\n");
/* Idle gart only and do upload on unmap */
//rmesa->rmm->u_list[id].fb = NULL;
if(rmesa->rmm->u_list[id].mapped == 1)
WARN_ONCE("buffer %d already mapped\n", id);
rmesa->rmm->u_list[id].mapped = 1;
ptr = radeon_mm_ptr(rmesa, id);
return ptr;
}
if (access == RADEON_MM_R) {
if(rmesa->rmm->u_list[id].mapped == 1)
WARN_ONCE("buffer %d already mapped\n", id);
rmesa->rmm->u_list[id].mapped = 1;
ptr = radeon_mm_ptr(rmesa, id);
return ptr;
}
if (rmesa->rmm->u_list[id].h_pending)
r300FlushCmdBuf(rmesa, __FUNCTION__);
if (rmesa->rmm->u_list[id].h_pending) {
return NULL;
}
while(rmesa->rmm->u_list[id].age > radeonGetAge((radeonContextPtr)rmesa) && tries++ < 1000)
usleep(10);
if (tries >= 1000) {
fprintf(stderr, "Idling failed (%x vs %x)\n",
rmesa->rmm->u_list[id].age, radeonGetAge((radeonContextPtr)rmesa));
return NULL;
}
if(rmesa->rmm->u_list[id].mapped == 1)
WARN_ONCE("buffer %d already mapped\n", id);
rmesa->rmm->u_list[id].mapped = 1;
ptr = radeon_mm_ptr(rmesa, id);
return ptr;
}
void radeon_mm_unmap(r300ContextPtr rmesa, int id)
{
#ifdef MM_DEBUG
fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id, radeonGetAge((radeonContextPtr)rmesa));
#endif
assert(id <= rmesa->rmm->u_last);
if(rmesa->rmm->u_list[id].mapped == 0)
WARN_ONCE("buffer %d not mapped\n", id);
rmesa->rmm->u_list[id].mapped = 0;
if (rmesa->rmm->u_list[id].fb)
emit_lin_cp(rmesa, rmesa->radeon.radeonScreen->texOffset[0] + rmesa->rmm->u_list[id].fb->ofs,
r300GartOffsetFromVirtual(rmesa, rmesa->rmm->u_list[id].ptr),
rmesa->rmm->u_list[id].size);
}
void radeon_mm_free(r300ContextPtr rmesa, int id)
{
#ifdef MM_DEBUG
fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id, radeonGetAge((radeonContextPtr)rmesa));
#endif
assert(id <= rmesa->rmm->u_last);
if(id == 0)
return;
if(rmesa->rmm->u_list[id].ptr == NULL){
WARN_ONCE("Not allocated!\n");
return ;
}
if(rmesa->rmm->u_list[id].pending){
WARN_ONCE("%p already pended!\n", rmesa->rmm->u_list[id].ptr);
return ;
}
rmesa->rmm->u_list[id].pending = 1;
}
#endif

View File

@@ -1,40 +0,0 @@
#ifndef __RADEON_MM_H__
#define __RADEON_MM_H__
//#define RADEON_MM_PDL 0
#define RADEON_MM_UL 1
#define RADEON_MM_R 1
#define RADEON_MM_W 2
#define RADEON_MM_RW (RADEON_MM_R | RADEON_MM_W)
#define RADEON_MM_SCRATCH 2
struct radeon_memory_manager {
struct {
void *ptr;
uint32_t size;
uint32_t age;
uint32_t h_pending;
int pending;
int mapped;
int ref_count;
struct mem_block *fb;
} *u_list;
int u_head, u_tail, u_size, u_last;
};
extern void radeon_mm_init(r300ContextPtr rmesa);
extern void radeon_mm_destroy(r300ContextPtr rmesa);
extern void *radeon_mm_ptr(r300ContextPtr rmesa, int id);
extern int radeon_mm_find(r300ContextPtr rmesa, void *ptr);
extern int radeon_mm_alloc(r300ContextPtr rmesa, int alignment, int size);
extern void radeon_mm_use(r300ContextPtr rmesa, int id);
extern unsigned long radeon_mm_offset(r300ContextPtr rmesa, int id);
extern int radeon_mm_on_card(r300ContextPtr rmesa, int id);
extern void *radeon_mm_map(r300ContextPtr rmesa, int id, int access);
extern void radeon_mm_unmap(r300ContextPtr rmesa, int id);
extern void radeon_mm_free(r300ContextPtr rmesa, int id);
#endif

View File

@@ -39,9 +39,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Keith Whitwell <keith@tungstengraphics.com>
*
*/
#include <unistd.h>
#include "glheader.h"
#include "imports.h"
#include "swrast/swrast.h"
#include "r300_state.h"
@@ -51,10 +50,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "drirenderbuffer.h"
#define DBG 0
/*
* Note that all information needed to access pixels in a renderbuffer
* should be obtained through the gl_renderbuffer parameter, not per-context
@@ -85,8 +82,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define HW_UNLOCK()
/* ================================================================
* Color buffer
*/
@@ -101,7 +96,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define GET_PTR(X,Y) (buf + ((Y) * drb->flippedPitch + (X)) * 2)
#include "spantmp2.h"
/* 32 bit, ARGB8888 color spanline and pixel functions
*/
#define SPANTMP_PIXEL_FMT GL_BGRA
@@ -112,7 +106,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define GET_PTR(X,Y) (buf + ((Y) * drb->flippedPitch + (X)) * 4)
#include "spantmp2.h"
/* ================================================================
* Depth buffer
*/
@@ -127,59 +120,56 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* too...
*/
static GLuint
radeon_mba_z32( const driRenderbuffer *drb, GLint x, GLint y )
static GLuint radeon_mba_z32(const driRenderbuffer * drb, GLint x, GLint y)
{
GLuint pitch = drb->pitch;
if (1 /*|| drb->depthHasSurface */) {
return 4 * (x + y * pitch);
}
else {
GLuint ba, address = 0; /* a[0..1] = 0 */
GLuint pitch = drb->pitch;
if (drb->depthHasSurface) {
return 4 * (x + y * pitch);
} else {
GLuint ba, address = 0; /* a[0..1] = 0 */
ba = (y / 8) * (pitch / 8) + (x / 8);
#ifdef COMPILE_R300
ba = (y / 8) * (pitch / 8) + (x / 8);
#else
ba = (y / 16) * (pitch / 16) + (x / 16);
#endif
address |= (x & 0x7) << 2; /* a[2..4] = x[0..2] */
address |= (y & 0x3) << 5; /* a[5..6] = y[0..1] */
address |=
(((x & 0x10) >> 2) ^ (y & 0x4)) << 5; /* a[7] = x[4] ^ y[2] */
address |= (ba & 0x3) << 8; /* a[8..9] = ba[0..1] */
address |= (x & 0x7) << 2; /* a[2..4] = x[0..2] */
address |= (y & 0x3) << 5; /* a[5..6] = y[0..1] */
address |= (((x & 0x10) >> 2) ^ (y & 0x4)) << 5; /* a[7] = x[4] ^ y[2] */
address |= (ba & 0x3) << 8; /* a[8..9] = ba[0..1] */
address |= (y & 0x8) << 7; /* a[10] = y[3] */
address |=
(((x & 0x8) << 1) ^ (y & 0x10)) << 7; /* a[11] = x[3] ^ y[4] */
address |= (ba & ~0x3) << 10; /* a[12..] = ba[2..] */
address |= (y & 0x8) << 7; /* a[10] = y[3] */
address |= (((x & 0x8) << 1) ^ (y & 0x10)) << 7; /* a[11] = x[3] ^ y[4] */
address |= (ba & ~0x3) << 10; /* a[12..] = ba[2..] */
return address;
}
return address;
}
}
static INLINE GLuint
radeon_mba_z16( const driRenderbuffer *drb, GLint x, GLint y )
radeon_mba_z16(const driRenderbuffer * drb, GLint x, GLint y)
{
GLuint pitch = drb->pitch;
if (1 /*|| drb->depthHasSurface */) {
return 2 * (x + y * pitch);
}
else {
GLuint ba, address = 0; /* a[0] = 0 */
GLuint pitch = drb->pitch;
if (drb->depthHasSurface) {
return 2 * (x + y * pitch);
} else {
GLuint ba, address = 0; /* a[0] = 0 */
ba = (y / 16) * (pitch / 32) + (x / 32);
ba = (y / 16) * (pitch / 32) + (x / 32);
address |= (x & 0x7) << 1; /* a[1..3] = x[0..2] */
address |= (y & 0x7) << 4; /* a[4..6] = y[0..2] */
address |= (x & 0x8) << 4; /* a[7] = x[3] */
address |= (ba & 0x3) << 8; /* a[8..9] = ba[0..1] */
address |= (y & 0x8) << 7; /* a[10] = y[3] */
address |= ((x & 0x10) ^ (y & 0x10)) << 7;/* a[11] = x[4] ^ y[4] */
address |= (ba & ~0x3) << 10; /* a[12..] = ba[2..] */
address |= (x & 0x7) << 1; /* a[1..3] = x[0..2] */
address |= (y & 0x7) << 4; /* a[4..6] = y[0..2] */
address |= (x & 0x8) << 4; /* a[7] = x[3] */
address |= (ba & 0x3) << 8; /* a[8..9] = ba[0..1] */
address |= (y & 0x8) << 7; /* a[10] = y[3] */
address |= ((x & 0x10) ^ (y & 0x10)) << 7; /* a[11] = x[4] ^ y[4] */
address |= (ba & ~0x3) << 10; /* a[12..] = ba[2..] */
return address;
}
return address;
}
}
/* 16-bit depth buffer functions
*/
#define WRITE_DEPTH( _x, _y, d ) \
@@ -191,12 +181,12 @@ radeon_mba_z16( const driRenderbuffer *drb, GLint x, GLint y )
#define TAG(x) radeon##x##_z16
#include "depthtmp.h"
/* 24 bit depth, 8 bit stencil depthbuffer functions
*
* Careful: It looks like the R300 uses ZZZS byte order while the R200
* uses SZZZ for 24 bit depth, 8 bit stencil mode.
*/
#ifdef COMPILE_R300
#define WRITE_DEPTH( _x, _y, d ) \
do { \
GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo ); \
@@ -205,23 +195,39 @@ do { \
tmp |= ((d << 8) & 0xffffff00); \
*(GLuint *)(buf + offset) = tmp; \
} while (0)
#else
#define WRITE_DEPTH( _x, _y, d ) \
do { \
GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo ); \
GLuint tmp = *(GLuint *)(buf + offset); \
tmp &= 0xff000000; \
tmp |= ((d) & 0x00ffffff); \
*(GLuint *)(buf + offset) = tmp; \
} while (0)
#endif
#ifdef COMPILE_R300
#define READ_DEPTH( d, _x, _y ) \
do { \
d = (*(GLuint *)(buf + radeon_mba_z32( drb, _x + xo, \
_y + yo )) & 0xffffff00) >> 8; \
}while(0)
#else
#define READ_DEPTH( d, _x, _y ) \
d = *(GLuint *)(buf + radeon_mba_z32( drb, _x + xo, \
_y + yo )) & 0x00ffffff;
#endif
#define TAG(x) radeon##x##_z24_s8
#include "depthtmp.h"
/* ================================================================
* Stencil buffer
*/
/* 24 bit depth, 8 bit stencil depthbuffer functions
*/
#ifdef COMPILE_R300
#define WRITE_STENCIL( _x, _y, d ) \
do { \
GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo ); \
@@ -230,95 +236,86 @@ do { \
tmp |= (d) & 0xff; \
*(GLuint *)(buf + offset) = tmp; \
} while (0)
#else
#define WRITE_STENCIL( _x, _y, d ) \
do { \
GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo ); \
GLuint tmp = *(GLuint *)(buf + offset); \
tmp &= 0x00ffffff; \
tmp |= (((d) & 0xff) << 24); \
*(GLuint *)(buf + offset) = tmp; \
} while (0)
#endif
#ifdef COMPILE_R300
#define READ_STENCIL( d, _x, _y ) \
do { \
GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo ); \
GLuint tmp = *(GLuint *)(buf + offset); \
d = tmp & 0x000000ff; \
} while (0)
#else
#define READ_STENCIL( d, _x, _y ) \
do { \
GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo ); \
GLuint tmp = *(GLuint *)(buf + offset); \
d = (tmp & 0xff000000) >> 24; \
} while (0)
#endif
#define TAG(x) radeon##x##_z24_s8
#include "stenciltmp.h"
/* Move locking out to get reasonable span performance (10x better
* than doing this in HW_LOCK above). WaitForIdle() is the main
* culprit.
*/
static void radeonSpanRenderStart( GLcontext *ctx )
static void radeonSpanRenderStart(GLcontext * ctx)
{
radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
{
static int first = 1;
r300ContextPtr r300 = (r300ContextPtr)rmesa;
if (first) {
r300->span_dlocking = getenv("R300_SPAN_DISABLE_LOCKING") ? 1 : 0;
if (r300->span_dlocking == 0) {
fprintf(stderr, "Try R300_SPAN_DISABLE_LOCKING env var if this hangs.\n");
fflush(stderr);
sleep(1);
}
first = 0;
}
if (r300->span_dlocking) {
r300Flush(ctx);
LOCK_HARDWARE( rmesa );
radeonWaitForIdleLocked( rmesa );
UNLOCK_HARDWARE( rmesa );
return;
}
}
// R300_FIREVERTICES( rmesa );
// old code has flush
r300Flush(ctx);
LOCK_HARDWARE( rmesa );
radeonWaitForIdleLocked( rmesa );
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
#ifdef COMPILE_R300
r300ContextPtr r300 = (r300ContextPtr) rmesa;
R300_FIREVERTICES(r300);
#else
RADEON_FIREVERTICES(rmesa);
#endif
LOCK_HARDWARE(rmesa);
radeonWaitForIdleLocked(rmesa);
}
static void radeonSpanRenderFinish( GLcontext *ctx )
static void radeonSpanRenderFinish(GLcontext * ctx)
{
radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
r300ContextPtr r300 = (r300ContextPtr)rmesa;
_swrast_flush( ctx );
if (r300->span_dlocking == 0)
UNLOCK_HARDWARE( rmesa );
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
_swrast_flush(ctx);
UNLOCK_HARDWARE(rmesa);
}
void radeonInitSpanFuncs( GLcontext *ctx )
void radeonInitSpanFuncs(GLcontext * ctx)
{
struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
swdd->SpanRenderStart = radeonSpanRenderStart;
swdd->SpanRenderFinish = radeonSpanRenderFinish;
struct swrast_device_driver *swdd =
_swrast_GetDeviceDriverReference(ctx);
swdd->SpanRenderStart = radeonSpanRenderStart;
swdd->SpanRenderFinish = radeonSpanRenderFinish;
}
/**
* Plug in the Get/Put routines for the given driRenderbuffer.
*/
void
radeonSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
void radeonSetSpanFunctions(driRenderbuffer * drb, const GLvisual * vis)
{
if (drb->Base.InternalFormat == GL_RGBA) {
if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
radeonInitPointers_RGB565(&drb->Base);
}
else {
radeonInitPointers_ARGB8888(&drb->Base);
}
}
else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
radeonInitDepthPointers_z16(&drb->Base);
}
else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
radeonInitDepthPointers_z24_s8(&drb->Base);
}
else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
radeonInitStencilPointers_z24_s8(&drb->Base);
}
if (drb->Base.InternalFormat == GL_RGBA) {
if (vis->redBits == 5 && vis->greenBits == 6
&& vis->blueBits == 5) {
radeonInitPointers_RGB565(&drb->Base);
} else {
radeonInitPointers_ARGB8888(&drb->Base);
}
} else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
radeonInitDepthPointers_z16(&drb->Base);
} else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
radeonInitDepthPointers_z24_s8(&drb->Base);
} else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
radeonInitStencilPointers_z24_s8(&drb->Base);
}
}

View File

@@ -1,46 +0,0 @@
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
initial release of the Radeon 8500 driver under the XFree86 license.
This notice must be preserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice (including the
next paragraph) shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
/*
* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
*/
#ifndef __RADEON_SPAN_H__
#define __RADEON_SPAN_H__
#ifdef GLX_DIRECT_RENDERING
#include "drirenderbuffer.h"
extern void radeonInitSpanFuncs(GLcontext * ctx);
extern void radeonSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
#endif
#endif

View File

@@ -154,7 +154,8 @@ void radeonSetCliprects(radeonContextPtr radeon)
if (draw_fb->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT) {
/* Can't ignore 2d windows if we are page flipping. */
if (drawable->numBackClipRects == 0 || radeon->doPageFlip) {
if (drawable->numBackClipRects == 0 || radeon->doPageFlip ||
radeon->sarea->pfCurrentPage == 1) {
radeon->numClipRects = drawable->numClipRects;
radeon->pClipRects = drawable->pClipRects;
} else {

View File

@@ -31,8 +31,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef __RADEON_STATE_H__
#define __RADEON_STATE_H__
#include "radeon_context.h"
extern void radeonRecalcScissorRects(radeonContextPtr radeon);
extern void radeonSetCliprects(radeonContextPtr radeon);
extern void radeonUpdateScissor(GLcontext* ctx);

View File

@@ -1,656 +0,0 @@
/*
* Copyright (C) 2005 Aapo Tahkola.
*
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
/*
* Authors:
* Aapo Tahkola <aet@rasterburn.org>
*/
#include "context.h"
#include "r300_context.h"
#include "r300_cmdbuf.h"
#include "r300_ioctl.h"
#include "r300_maos.h"
#include "r300_state.h"
#include "radeon_mm.h"
#include "hash.h"
#include "dispatch.h"
#include "bufferobj.h"
#include "vtxfmt.h"
#include "api_validate.h"
#include "state.h"
#include "image.h"
#include "vbo/vbo_context.h"
#define CONV_VB(a, b) rvb->AttribPtr[(a)].size = vb->b->size, \
rvb->AttribPtr[(a)].type = GL_FLOAT, \
rvb->AttribPtr[(a)].stride = vb->b->stride, \
rvb->AttribPtr[(a)].data = vb->b->data
void radeon_vb_to_rvb(r300ContextPtr rmesa, struct radeon_vertex_buffer *rvb, struct vertex_buffer *vb)
{
int i;
GLcontext *ctx;
ctx = rmesa->radeon.glCtx;
memset(rvb, 0, sizeof(*rvb));
rvb->Elts = vb->Elts;
rvb->elt_size = 4;
rvb->elt_min = 0;
rvb->elt_max = vb->Count;
rvb->Count = vb->Count;
CONV_VB(VERT_ATTRIB_POS, ObjPtr);
CONV_VB(VERT_ATTRIB_NORMAL, NormalPtr);
CONV_VB(VERT_ATTRIB_COLOR0, ColorPtr[0]);
CONV_VB(VERT_ATTRIB_COLOR1, SecondaryColorPtr[0]);
CONV_VB(VERT_ATTRIB_FOG, FogCoordPtr);
for (i=0; i < ctx->Const.MaxTextureCoordUnits; i++)
CONV_VB(VERT_ATTRIB_TEX0 + i, TexCoordPtr[i]);
for (i=0; i < MAX_VERTEX_PROGRAM_ATTRIBS; i++)
CONV_VB(VERT_ATTRIB_GENERIC0 + i, AttribPtr[VERT_ATTRIB_GENERIC0 + i]);
rvb->Primitive = vb->Primitive;
rvb->PrimitiveCount = vb->PrimitiveCount;
rvb->LockFirst = rvb->LockCount = 0;
rvb->lock_uptodate = GL_FALSE;
}
#ifdef RADEON_VTXFMT_A
extern void _tnl_array_init( GLcontext *ctx );
#define CONV(a, b) \
do { \
if (ctx->Array.ArrayObj->b.Enabled) { \
rmesa->state.VB.AttribPtr[(a)].size = ctx->Array.ArrayObj->b.Size; \
rmesa->state.VB.AttribPtr[(a)].data = ctx->Array.ArrayObj->b.BufferObj->Name \
? (void *)ADD_POINTERS(ctx->Array.ArrayObj->b.Ptr, ctx->Array.ArrayObj->b.BufferObj->Data) \
: (void *)ctx->Array.ArrayObj->b.Ptr; \
rmesa->state.VB.AttribPtr[(a)].stride = ctx->Array.ArrayObj->b.StrideB; \
rmesa->state.VB.AttribPtr[(a)].type = ctx->Array.ArrayObj->b.Type; \
enabled |= 1 << (a); \
} \
} while (0)
static int setup_arrays(r300ContextPtr rmesa, GLint start)
{
int i;
struct dt def = { 4, GL_FLOAT, 0, NULL };
GLcontext *ctx;
GLuint enabled = 0;
ctx = rmesa->radeon.glCtx;
i = r300Fallback(ctx);
if (i)
return i;
memset(rmesa->state.VB.AttribPtr, 0, VERT_ATTRIB_MAX*sizeof(struct dt));
CONV(VERT_ATTRIB_POS, Vertex);
CONV(VERT_ATTRIB_NORMAL, Normal);
CONV(VERT_ATTRIB_COLOR0, Color);
CONV(VERT_ATTRIB_COLOR1, SecondaryColor);
CONV(VERT_ATTRIB_FOG, FogCoord);
for (i=0; i < MAX_TEXTURE_COORD_UNITS; i++)
CONV(VERT_ATTRIB_TEX0 + i, TexCoord[i]);
if (ctx->VertexProgram._Enabled)
for (i=0; i < VERT_ATTRIB_MAX; i++)
CONV(i, VertexAttrib[i]);
for (i=0; i < VERT_ATTRIB_MAX; i++) {
rmesa->state.VB.AttribPtr[i].data += rmesa->state.VB.AttribPtr[i].stride * start;
}
for(i=0; i < VERT_ATTRIB_MAX; i++){
if(rmesa->state.VB.AttribPtr[i].type != GL_UNSIGNED_BYTE &&
#if MESA_LITTLE_ENDIAN
rmesa->state.VB.AttribPtr[i].type != GL_SHORT &&
#endif
rmesa->state.VB.AttribPtr[i].type != GL_FLOAT){
WARN_ONCE("Unsupported format %d at index %d\n", rmesa->state.VB.AttribPtr[i].type, i);
return R300_FALLBACK_TCL;
}
/*fprintf(stderr, "%d: ", i);
switch(rmesa->state.VB.AttribPtr[i].type){
case GL_BYTE: fprintf(stderr, "byte "); break;
case GL_UNSIGNED_BYTE: fprintf(stderr, "u byte "); break;
case GL_SHORT: fprintf(stderr, "short "); break;
case GL_UNSIGNED_SHORT: fprintf(stderr, "u short "); break;
case GL_INT: fprintf(stderr, "int "); break;
case GL_UNSIGNED_INT: fprintf(stderr, "u int "); break;
case GL_FLOAT: fprintf(stderr, "float "); break;
case GL_2_BYTES: fprintf(stderr, "2 bytes "); break;
case GL_3_BYTES: fprintf(stderr, "3 bytes "); break;
case GL_4_BYTES: fprintf(stderr, "4 bytes "); break;
case GL_DOUBLE: fprintf(stderr, "double "); break;
default: fprintf(stderr, "unknown "); break;
}
fprintf(stderr, "Size %d ", rmesa->state.VB.AttribPtr[i].size);
fprintf(stderr, "Ptr %p ", rmesa->state.VB.AttribPtr[i].data);
fprintf(stderr, "Stride %d ", rmesa->state.VB.AttribPtr[i].stride);
fprintf(stderr, "\n");*/
}
return R300_FALLBACK_NONE;
}
void radeon_init_vtxfmt_a(r300ContextPtr rmesa);
static void radeonDrawRangeElements(GLcontext *ctx,
GLenum mode,
GLuint min,
GLuint max,
GLsizei count,
GLenum type,
const GLvoid *c_indices)
{
#if 1
return GL_FALSE;
#else
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct tnl_prim prim;
int elt_size;
int i;
void *ptr = NULL;
struct r300_dma_region rvb;
const GLvoid *indices = c_indices;
if (count > 65535) {
/* TODO */
if (mode == GL_POINTS ||
mode == GL_LINES ||
mode == GL_QUADS ||
mode == GL_TRIANGLES) {
while (count) {
i = r300_get_num_verts(rmesa, MIN2(count, 65535), mode);
radeonDrawRangeElements(mode, min, max, i, type, indices);
indices += i * _mesa_sizeof_type(type);
count -= i;
}
return GL_TRUE;
}
WARN_ONCE("Too many verts!\n");
return GL_FALSE;
}
if (ctx->Array.ElementArrayBufferObj->Name) {
/* use indices in the buffer object */
if (!ctx->Array.ElementArrayBufferObj->Data) {
_mesa_warning(ctx, "DrawRangeElements with empty vertex elements buffer!");
return GL_TRUE;
}
/* actual address is the sum of pointers */
indices = (GLvoid *)
ADD_POINTERS(ctx->Array.ElementArrayBufferObj->Data, (const GLubyte *) c_indices);
}
FLUSH_CURRENT( ctx, 0 );
#ifdef OPTIMIZE_ELTS
min = 0;
#endif
memset(&rvb, 0, sizeof(rvb));
switch (type){
case GL_UNSIGNED_BYTE:
#ifdef FORCE_32BITS_ELTS
elt_size = 4;
#else
elt_size = 2;
#endif
r300AllocDmaRegion(rmesa, &rvb, count * elt_size, elt_size);
rvb.aos_offset = GET_START(&rvb);
ptr = rvb.address + rvb.start;
#ifdef FORCE_32BITS_ELTS
for(i=0; i < count; i++)
((unsigned int *)ptr)[i] = ((unsigned char *)indices)[i] - min;
#else
for(i=0; i < count; i++)
((unsigned short int *)ptr)[i] = ((unsigned char *)indices)[i] - min;
#endif
break;
case GL_UNSIGNED_SHORT:
#ifdef FORCE_32BITS_ELTS
elt_size = 4;
#else
elt_size = 2;
#endif
#ifdef OPTIMIZE_ELTS
if (min == 0 && ctx->Array.ElementArrayBufferObj->Name){
ptr = indices;
break;
}
#endif
r300AllocDmaRegion(rmesa, &rvb, count * elt_size, elt_size);
rvb.aos_offset = GET_START(&rvb);
ptr = rvb.address + rvb.start;
#ifdef FORCE_32BITS_ELTS
for(i=0; i < count; i++)
((unsigned int *)ptr)[i] = ((unsigned short int *)indices)[i] - min;
#else
for(i=0; i < count; i++)
((unsigned short int *)ptr)[i] = ((unsigned short int *)indices)[i] - min;
#endif
break;
case GL_UNSIGNED_INT:
#ifdef FORCE_32BITS_ELTS
elt_size = 4;
#else
if (max - min <= 65535)
elt_size = 2;
else
elt_size = 4;
#endif
r300AllocDmaRegion(rmesa, &rvb, count * elt_size, elt_size);
rvb.aos_offset = GET_START(&rvb);
ptr = rvb.address + rvb.start;
if (elt_size == 2)
for (i=0; i < count; i++)
((unsigned short int *)ptr)[i] = ((unsigned int *)indices)[i] - min;
else
for (i=0; i < count; i++)
((unsigned int *)ptr)[i] = ((unsigned int *)indices)[i] - min;
break;
default:
WARN_ONCE("Unknown elt type!\n");
return GL_FALSE;
}
/* XXX: setup_arrays before state update? */
if (ctx->NewState)
_mesa_update_state( ctx );
r300UpdateShaders(rmesa);
if (setup_arrays(rmesa, min) >= R300_FALLBACK_TCL) {
r300ReleaseDmaRegion(rmesa, &rvb, __FUNCTION__);
return GL_FALSE;
}
rmesa->state.VB.Count = max - min + 1;
r300UpdateShaderStates(rmesa);
rmesa->state.VB.Primitive = &prim;
rmesa->state.VB.PrimitiveCount = 1;
prim.mode = mode | PRIM_BEGIN | PRIM_END;
if (rmesa->state.VB.LockCount)
prim.start = min - rmesa->state.VB.LockFirst;
else
prim.start = 0;
prim.count = count;
rmesa->state.VB.Elts = ptr;
rmesa->state.VB.elt_size = elt_size;
rmesa->state.VB.elt_min = min;
rmesa->state.VB.elt_max = max;
if (r300_run_vb_render(ctx, NULL)) {
r300ReleaseDmaRegion(rmesa, &rvb, __FUNCTION__);
return GL_FALSE;
}
if(rvb.buf)
radeon_mm_use(rmesa, rvb.buf->id);
r300ReleaseDmaRegion(rmesa, &rvb, __FUNCTION__);
return GL_TRUE;
#endif
}
static GLboolean radeonDrawArrays( GLcontext *ctx,
GLenum mode, GLint start, GLsizei count )
{
#if 1
return GL_FALSE;
#else
GET_CURRENT_CONTEXT(ctx);
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct tnl_prim prim;
if (count > 65535) {
/* TODO: split into multiple draws.
*/
WARN_ONCE("Too many verts!\n");
return GL_FALSE;
}
FLUSH_CURRENT( ctx, 0 );
if (ctx->NewState)
_mesa_update_state( ctx );
/* XXX: setup_arrays before state update? */
r300UpdateShaders(rmesa);
if (setup_arrays(rmesa, start) >= R300_FALLBACK_TCL)
return GL_FALSE;
rmesa->state.VB.Count = count;
r300UpdateShaderStates(rmesa);
rmesa->state.VB.Primitive = &prim;
rmesa->state.VB.PrimitiveCount = 1;
prim.mode = mode | PRIM_BEGIN | PRIM_END;
if (rmesa->state.VB.LockCount)
prim.start = start - rmesa->state.VB.LockFirst;
else
prim.start = 0;
prim.count = count;
rmesa->state.VB.Elts = NULL;
rmesa->state.VB.elt_size = 0;
rmesa->state.VB.elt_min = 0;
rmesa->state.VB.elt_max = 0;
if (r300_run_vb_render(ctx, NULL))
return GL_FALSE;
return GL_TRUE;
#endif
}
static void radeon_draw_prims( GLcontext *ctx,
const struct gl_client_array *arrays[],
const struct _mesa_prim *prim,
GLuint nr_prims,
const struct _mesa_index_buffer *ib,
GLuint min_index,
GLuint max_index)
{
if (ib == NULL) {
for (i = 0; i < nr_prims; i++) {
if (!radeonDrawArrays(ctx,
prim->mode,
prim->start,
prim->count)) {
/* Fallback
*/
_tnl_draw_prims(ctx,
arrays,
prim + i,
nr_prims - i,
ib,
min_index,
max_index);
return;
}
}
} else {
for (i = 0; i < nr_prims; i++) {
if (!radeonDrawRangeElements(ctx,
prim->mode,
min_index,
max_index,
prim->count,
ib->types,
ib->ptr)) {
/* Fallback
*/
_tnl_draw_prims(ctx,
arrays,
prim + i,
nr_prims - i,
ib,
min_index,
max_index);
return;
}
}
}
}
void radeon_init_vtxfmt_a(r300ContextPtr rmesa)
{
GLcontext *ctx;
struct vbo_context *vbo = vbo_context(ctx);
vbo->draw_prims = radeon_draw_prims;
}
#endif
#ifdef HW_VBOS
static struct gl_buffer_object *
r300NewBufferObject(GLcontext *ctx, GLuint name, GLenum target )
{
struct r300_buffer_object *obj;
(void) ctx;
obj = MALLOC_STRUCT(r300_buffer_object);
_mesa_initialize_buffer_object(&obj->mesa_obj, name, target);
return &obj->mesa_obj;
}
static void r300BufferData(GLcontext *ctx, GLenum target, GLsizeiptrARB size,
const GLvoid *data, GLenum usage, struct gl_buffer_object *obj)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct r300_buffer_object *r300_obj = (struct r300_buffer_object *)obj;
/* Free previous buffer */
if (obj->OnCard) {
radeon_mm_free(rmesa, r300_obj->id);
obj->OnCard = GL_FALSE;
} else {
if (obj->Data)
_mesa_free(obj->Data);
}
#ifdef OPTIMIZE_ELTS
if (0) {
#else
if (target == GL_ELEMENT_ARRAY_BUFFER_ARB) {
#endif
fallback:
obj->Data = malloc(size);
if (data)
_mesa_memcpy(obj->Data, data, size);
obj->OnCard = GL_FALSE;
} else {
r300_obj->id = radeon_mm_alloc(rmesa, 4, size);
if (r300_obj->id == 0)
goto fallback;
obj->Data = radeon_mm_map(rmesa, r300_obj->id, RADEON_MM_W);
if (data)
_mesa_memcpy(obj->Data, data, size);
radeon_mm_unmap(rmesa, r300_obj->id);
obj->OnCard = GL_TRUE;
}
obj->Size = size;
obj->Usage = usage;
}
static void r300BufferSubData(GLcontext *ctx, GLenum target, GLintptrARB offset,
GLsizeiptrARB size, const GLvoid * data, struct gl_buffer_object * bufObj)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct r300_buffer_object *r300_obj = (struct r300_buffer_object *)bufObj;
(void) ctx; (void) target;
void *ptr;
if (bufObj->Data && ((GLuint) (size + offset) <= bufObj->Size)) {
if (bufObj->OnCard){
ptr = radeon_mm_map(rmesa, r300_obj->id, RADEON_MM_W);
_mesa_memcpy( (GLubyte *) ptr + offset, data, size );
radeon_mm_unmap(rmesa, r300_obj->id);
} else {
_mesa_memcpy( (GLubyte *) bufObj->Data + offset, data, size );
}
}
}
static void *r300MapBuffer(GLcontext *ctx, GLenum target, GLenum access,
struct gl_buffer_object *bufObj)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct r300_buffer_object *r300_obj = (struct r300_buffer_object *)bufObj;
(void) ctx;
(void) target;
(void) access;
//ASSERT(!bufObj->OnCard);
/* Just return a direct pointer to the data */
if (bufObj->Pointer) {
/* already mapped! */
return NULL;
}
if (!bufObj->OnCard) {
bufObj->Pointer = bufObj->Data;
return bufObj->Pointer;
}
switch (access) {
case GL_READ_ONLY:
bufObj->Pointer = radeon_mm_map(rmesa, r300_obj->id, RADEON_MM_R);
break;
case GL_WRITE_ONLY:
bufObj->Pointer = radeon_mm_map(rmesa, r300_obj->id, RADEON_MM_W);
break;
case GL_READ_WRITE:
bufObj->Pointer = radeon_mm_map(rmesa, r300_obj->id, RADEON_MM_RW);
break;
default:
WARN_ONCE("Unknown access type\n");
bufObj->Pointer = NULL;
break;
}
return bufObj->Pointer;
}
static GLboolean r300UnmapBuffer(GLcontext *ctx, GLenum target, struct gl_buffer_object *bufObj)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct r300_buffer_object *r300_obj = (struct r300_buffer_object *)bufObj;
(void) ctx;
(void) target;
//ASSERT(!bufObj->OnCard);
/* XXX we might assert here that bufObj->Pointer is non-null */
if (!bufObj->OnCard) {
bufObj->Pointer = NULL;
return GL_TRUE;
}
radeon_mm_unmap(rmesa, r300_obj->id);
bufObj->Pointer = NULL;
return GL_TRUE;
}
static void r300DeleteBuffer(GLcontext *ctx, struct gl_buffer_object *obj)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct r300_buffer_object *r300_obj = (struct r300_buffer_object *)obj;
if (obj->OnCard) {
radeon_mm_free(rmesa, r300_obj->id);
obj->Data = NULL;
}
_mesa_delete_buffer_object(ctx, obj);
}
void r300_evict_vbos(GLcontext *ctx, int amount)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct _mesa_HashTable *hash = ctx->Shared->BufferObjects;
GLuint k = _mesa_HashFirstEntry(hash);
while (amount > 0 && k) {
struct gl_buffer_object *obj = _mesa_lookup_bufferobj(ctx, k);
struct r300_buffer_object *r300_obj
= (struct r300_buffer_object *) obj;
if (obj->OnCard && obj->Size) {
GLvoid *data;
obj->Data = _mesa_malloc(obj->Size);
data = radeon_mm_map(rmesa, r300_obj->id, RADEON_MM_R);
_mesa_memcpy(obj->Data, data, obj->Size);
radeon_mm_unmap(rmesa, r300_obj->id);
radeon_mm_free(rmesa, r300_obj->id);
r300_obj->id = 0;
obj->OnCard = GL_FALSE;
amount -= obj->Size;
}
k = _mesa_HashNextEntry(hash, k);
}
}
void r300_init_vbo_funcs(struct dd_function_table *functions)
{
functions->NewBufferObject = r300NewBufferObject;
functions->BufferData = r300BufferData;
functions->BufferSubData = r300BufferSubData;
functions->MapBuffer = r300MapBuffer;
functions->UnmapBuffer = r300UnmapBuffer;
functions->DeleteBuffer = r300DeleteBuffer;
}
#endif

View File

@@ -604,7 +604,6 @@ radeonMakeCurrent( __DRIcontextPrivate *driContextPriv,
newCtx->dri.drawable = driDrawPriv;
radeonSetCliprects(newCtx);
radeonUpdateWindow( newCtx->glCtx );
radeonUpdateViewportOffset( newCtx->glCtx );
}
@@ -612,6 +611,7 @@ radeonMakeCurrent( __DRIcontextPrivate *driContextPriv,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
_mesa_update_state( newCtx->glCtx );
} else {
if (RADEON_DEBUG & DEBUG_DRI)
fprintf(stderr, "%s ctx is null\n", __FUNCTION__);

View File

@@ -1,8 +1,12 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_context.h,v 1.6 2002/12/16 16:18:58 dawes Exp $ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
VA Linux Systems Inc., Fremont, California.
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
initial release of the Radeon 8500 driver under the XFree86 license.
This notice must be preserved.
All Rights Reserved.
@@ -30,9 +34,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
* Kevin E. Martin <martin@valinux.com>
* Gareth Hughes <gareth@valinux.com>
* Keith Whitwell <keith@tungstengraphics.com>
* Kevin E. Martin <martin@valinux.com>
* Nicolai Haehnle <prefect_@gmx.net>
*/
#ifndef __RADEON_CONTEXT_H__
@@ -54,7 +59,10 @@ typedef struct radeon_context *radeonContextPtr;
/* This union is used to avoid warnings/miscompilation
with float to uint32_t casts due to strict-aliasing */
typedef union { GLfloat f; uint32_t ui32; } float_ui32_type;
typedef union {
GLfloat f;
uint32_t ui32;
} float_ui32_type;
#include "radeon_lock.h"
#include "radeon_screen.h"
@@ -62,8 +70,13 @@ typedef union { GLfloat f; uint32_t ui32; } float_ui32_type;
#include "math/m_vector.h"
/* Flags for software fallback cases */
/* See correponding strings in radeon_swtcl.c */
#define TEX_0 0x1
#define TEX_1 0x2
#define TEX_2 0x4
#define TEX_ALL 0x7
/* Rasterizing fallbacks */
/* See correponding strings in r200_swtcl.c */
#define RADEON_FALLBACK_TEXTURE 0x0001
#define RADEON_FALLBACK_DRAW_BUFFER 0x0002
#define RADEON_FALLBACK_STENCIL 0x0004
@@ -84,46 +97,41 @@ typedef union { GLfloat f; uint32_t ui32; } float_ui32_type;
#include "tnl_dd/t_dd_vertex.h"
#undef TAG
typedef void (*radeon_tri_func)( radeonContextPtr,
typedef void (*radeon_tri_func) (radeonContextPtr,
radeonVertex *,
radeonVertex *,
radeonVertex * );
radeonVertex *, radeonVertex *);
typedef void (*radeon_line_func)( radeonContextPtr,
radeonVertex *,
radeonVertex * );
typedef void (*radeon_point_func)( radeonContextPtr,
radeonVertex * );
typedef void (*radeon_line_func) (radeonContextPtr,
radeonVertex *, radeonVertex *);
typedef void (*radeon_point_func) (radeonContextPtr, radeonVertex *);
struct radeon_colorbuffer_state {
GLuint clear;
int roundEnable;
GLuint clear;
int roundEnable;
};
struct radeon_depthbuffer_state {
GLuint clear;
GLfloat scale;
GLuint clear;
GLfloat scale;
};
struct radeon_scissor_state {
drm_clip_rect_t rect;
GLboolean enabled;
drm_clip_rect_t rect;
GLboolean enabled;
GLuint numClipRects; /* Cliprects active */
GLuint numAllocedClipRects; /* Cliprects available */
drm_clip_rect_t *pClipRects;
GLuint numClipRects; /* Cliprects active */
GLuint numAllocedClipRects; /* Cliprects available */
drm_clip_rect_t *pClipRects;
};
struct radeon_stencilbuffer_state {
GLboolean hwBuffer;
GLuint clear; /* rb3d_stencilrefmask value */
GLboolean hwBuffer;
GLuint clear; /* rb3d_stencilrefmask value */
};
struct radeon_stipple_state {
GLuint mask[32];
GLuint mask[32];
};
/* used for both tcl_vtx and vc_frmt tex bits (they are identical) */
@@ -133,70 +141,61 @@ struct radeon_stipple_state {
#define RADEON_Q_BIT(unit) \
(unit == 0 ? RADEON_CP_VC_FRMT_Q0 : (RADEON_CP_VC_FRMT_Q1 >> 2) << (2 * unit))
#define TEX_0 0x1
#define TEX_1 0x2
#define TEX_2 0x4
#define TEX_ALL 0x7
typedef struct radeon_tex_obj radeonTexObj, *radeonTexObjPtr;
/* Texture object in locally shared texture space.
*/
struct radeon_tex_obj {
driTextureObject base;
driTextureObject base;
GLuint bufAddr; /* Offset to start of locally
shared texture block */
GLuint bufAddr; /* Offset to start of locally
shared texture block */
GLuint dirty_state; /* Flags (1 per texunit) for
whether or not this texobj
has dirty hardware state
(pp_*) that needs to be
brought into the
texunit. */
GLuint dirty_state; /* Flags (1 per texunit) for
whether or not this texobj
has dirty hardware state
(pp_*) that needs to be
brought into the
texunit. */
drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS];
/* Six, for the cube faces */
drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS];
/* Six, for the cube faces */
GLuint pp_txfilter; /* hardware register values */
GLuint pp_txformat;
GLuint pp_txoffset; /* Image location in texmem.
All cube faces follow. */
GLuint pp_txsize; /* npot only */
GLuint pp_txpitch; /* npot only */
GLuint pp_border_color;
GLuint pp_cubic_faces; /* cube face 1,2,3,4 log2 sizes */
GLuint pp_txfilter; /* hardware register values */
GLuint pp_txformat;
GLuint pp_txoffset; /* Image location in texmem.
All cube faces follow. */
GLuint pp_txsize; /* npot only */
GLuint pp_txpitch; /* npot only */
GLuint pp_border_color;
GLuint pp_cubic_faces; /* cube face 1,2,3,4 log2 sizes */
GLboolean border_fallback;
GLboolean border_fallback;
GLuint tile_bits; /* hw texture tile bits used on this texture */
GLuint tile_bits; /* hw texture tile bits used on this texture */
};
struct radeon_texture_env_state {
radeonTexObjPtr texobj;
GLenum format;
GLenum envMode;
radeonTexObjPtr texobj;
GLenum format;
GLenum envMode;
};
struct radeon_texture_state {
struct radeon_texture_env_state unit[RADEON_MAX_TEXTURE_UNITS];
struct radeon_texture_env_state unit[RADEON_MAX_TEXTURE_UNITS];
};
struct radeon_state_atom {
struct radeon_state_atom *next, *prev;
const char *name; /* for debug */
int cmd_size; /* size in bytes */
GLuint is_tcl;
int *cmd; /* one or more cmd's */
int *lastcmd; /* one or more cmd's */
GLboolean dirty; /* dirty-mark in emit_state_list */
GLboolean (*check)( GLcontext * ); /* is this state active? */
struct radeon_state_atom *next, *prev;
const char *name; /* for debug */
int cmd_size; /* size in bytes */
GLuint is_tcl;
int *cmd; /* one or more cmd's */
int *lastcmd; /* one or more cmd's */
GLboolean dirty; /* dirty-mark in emit_state_list */
GLboolean(*check) (GLcontext *); /* is this state active? */
};
/* Trying to keep these relatively short as the variables are becoming
* extravagently long. Drop the driver name prefix off the front of
* everything - I think we know which driver we're in by now, and keep the
@@ -263,9 +262,9 @@ struct radeon_state_atom {
#define TEX_PP_BORDER_COLOR 8
#define TEX_STATE_SIZE 9
#define TXR_CMD_0 0 /* rectangle textures */
#define TXR_PP_TEX_SIZE 1 /* 0x1d04, 0x1d0c for NPOT! */
#define TXR_PP_TEX_PITCH 2 /* 0x1d08, 0x1d10 for NPOT! */
#define TXR_CMD_0 0 /* rectangle textures */
#define TXR_PP_TEX_SIZE 1 /* 0x1d04, 0x1d0c for NPOT! */
#define TXR_PP_TEX_PITCH 2 /* 0x1d08, 0x1d10 for NPOT! */
#define TXR_STATE_SIZE 3
#define CUBE_CMD_0 0
@@ -297,11 +296,11 @@ struct radeon_state_atom {
#define TCL_PER_LIGHT_CTL_3 11
#define TCL_STATE_SIZE 12
#define MTL_CMD_0 0
#define MTL_EMMISSIVE_RED 1
#define MTL_EMMISSIVE_GREEN 2
#define MTL_EMMISSIVE_BLUE 3
#define MTL_EMMISSIVE_ALPHA 4
#define MTL_CMD_0 0
#define MTL_EMMISSIVE_RED 1
#define MTL_EMMISSIVE_GREEN 2
#define MTL_EMMISSIVE_BLUE 3
#define MTL_EMMISSIVE_ALPHA 4
#define MTL_AMBIENT_RED 5
#define MTL_AMBIENT_GREEN 6
#define MTL_AMBIENT_BLUE 7
@@ -365,7 +364,7 @@ struct radeon_state_atom {
#define LIT_SPOT_EXPONENT 27
#define LIT_SPOT_CUTOFF 28
#define LIT_SPECULAR_THRESH 29
#define LIT_RANGE_CUTOFF 30 /* ? */
#define LIT_RANGE_CUTOFF 30 /* ? */
#define LIT_ATTEN_CONST_INV 31
#define LIT_STATE_SIZE 32
@@ -409,59 +408,54 @@ struct radeon_state_atom {
#define SHN_SHININESS 1
#define SHN_STATE_SIZE 2
struct radeon_hw_state {
/* Head of the linked list of state atoms. */
struct radeon_state_atom atomlist;
/* Head of the linked list of state atoms. */
struct radeon_state_atom atomlist;
/* Hardware state, stored as cmdbuf commands:
* -- Need to doublebuffer for
* - eliding noop statechange loops? (except line stipple count)
*/
struct radeon_state_atom ctx;
struct radeon_state_atom set;
struct radeon_state_atom lin;
struct radeon_state_atom msk;
struct radeon_state_atom vpt;
struct radeon_state_atom tcl;
struct radeon_state_atom msc;
struct radeon_state_atom tex[3];
struct radeon_state_atom cube[3];
struct radeon_state_atom zbs;
struct radeon_state_atom mtl;
struct radeon_state_atom mat[6];
struct radeon_state_atom lit[8]; /* includes vec, scl commands */
struct radeon_state_atom ucp[6];
struct radeon_state_atom eye; /* eye pos */
struct radeon_state_atom grd; /* guard band clipping */
struct radeon_state_atom fog;
struct radeon_state_atom glt;
struct radeon_state_atom txr[3]; /* for NPOT */
/* Hardware state, stored as cmdbuf commands:
* -- Need to doublebuffer for
* - eliding noop statechange loops? (except line stipple count)
*/
struct radeon_state_atom ctx;
struct radeon_state_atom set;
struct radeon_state_atom lin;
struct radeon_state_atom msk;
struct radeon_state_atom vpt;
struct radeon_state_atom tcl;
struct radeon_state_atom msc;
struct radeon_state_atom tex[3];
struct radeon_state_atom cube[3];
struct radeon_state_atom zbs;
struct radeon_state_atom mtl;
struct radeon_state_atom mat[6];
struct radeon_state_atom lit[8]; /* includes vec, scl commands */
struct radeon_state_atom ucp[6];
struct radeon_state_atom eye; /* eye pos */
struct radeon_state_atom grd; /* guard band clipping */
struct radeon_state_atom fog;
struct radeon_state_atom glt;
struct radeon_state_atom txr[3]; /* for NPOT */
int max_state_size; /* Number of bytes necessary for a full state emit. */
GLboolean is_dirty, all_dirty;
int max_state_size; /* Number of bytes necessary for a full state emit. */
GLboolean is_dirty, all_dirty;
};
struct radeon_state {
/* Derived state for internal purposes:
*/
struct radeon_colorbuffer_state color;
struct radeon_depthbuffer_state depth;
struct radeon_scissor_state scissor;
struct radeon_stencilbuffer_state stencil;
struct radeon_stipple_state stipple;
struct radeon_texture_state texture;
/* Derived state for internal purposes:
*/
struct radeon_colorbuffer_state color;
struct radeon_depthbuffer_state depth;
struct radeon_scissor_state scissor;
struct radeon_stencilbuffer_state stencil;
struct radeon_stipple_state stipple;
struct radeon_texture_state texture;
};
/* Need refcounting on dma buffers:
*/
struct radeon_dma_buffer {
int refcount; /* the number of retained regions in buf */
drmBufPtr buf;
int refcount; /* the number of retained regions in buf */
drmBufPtr buf;
};
#define GET_START(rvb) (rmesa->radeonScreen->gart_buffer_offset + \
@@ -471,139 +465,130 @@ struct radeon_dma_buffer {
/* A retained region, eg vertices for indexed vertices.
*/
struct radeon_dma_region {
struct radeon_dma_buffer *buf;
char *address; /* == buf->address */
int start, end, ptr; /* offsets from start of buf */
int aos_start;
int aos_stride;
int aos_size;
struct radeon_dma_buffer *buf;
char *address; /* == buf->address */
int start, end, ptr; /* offsets from start of buf */
int aos_start;
int aos_stride;
int aos_size;
};
struct radeon_dma {
/* Active dma region. Allocations for vertices and retained
* regions come from here. Also used for emitting random vertices,
* these may be flushed by calling flush_current();
*/
struct radeon_dma_region current;
void (*flush)( radeonContextPtr );
/* Active dma region. Allocations for vertices and retained
* regions come from here. Also used for emitting random vertices,
* these may be flushed by calling flush_current();
*/
struct radeon_dma_region current;
char *buf0_address; /* start of buf[0], for index calcs */
GLuint nr_released_bufs; /* flush after so many buffers released */
void (*flush) (radeonContextPtr);
char *buf0_address; /* start of buf[0], for index calcs */
GLuint nr_released_bufs; /* flush after so many buffers released */
};
struct radeon_dri_mirror {
__DRIcontextPrivate *context; /* DRI context */
__DRIscreenPrivate *screen; /* DRI screen */
__DRIcontextPrivate *context; /* DRI context */
__DRIscreenPrivate *screen; /* DRI screen */
/**
* DRI drawable bound to this context for drawing.
*/
__DRIdrawablePrivate *drawable;
__DRIdrawablePrivate *drawable;
/**
* DRI drawable bound to this context for reading.
*/
__DRIdrawablePrivate *readable;
__DRIdrawablePrivate *readable;
drm_context_t hwContext;
drm_hw_lock_t *hwLock;
int fd;
int drmMinor;
drm_context_t hwContext;
drm_hw_lock_t *hwLock;
int fd;
int drmMinor;
};
#define RADEON_CMD_BUF_SZ (8*1024)
#define RADEON_CMD_BUF_SZ (8*1024)
struct radeon_store {
GLuint statenr;
GLuint primnr;
char cmd_buf[RADEON_CMD_BUF_SZ];
int cmd_used;
int elts_start;
GLuint statenr;
GLuint primnr;
char cmd_buf[RADEON_CMD_BUF_SZ];
int cmd_used;
int elts_start;
};
/* radeon_tcl.c
*/
struct radeon_tcl_info {
GLuint vertex_format;
GLuint hw_primitive;
GLuint vertex_format;
GLuint hw_primitive;
/* Temporary for cases where incoming vertex data is incompatible
* with maos code.
*/
GLvector4f ObjClean;
/* Temporary for cases where incoming vertex data is incompatible
* with maos code.
*/
GLvector4f ObjClean;
struct radeon_dma_region *aos_components[8];
GLuint nr_aos_components;
struct radeon_dma_region *aos_components[8];
GLuint nr_aos_components;
GLuint *Elts;
GLuint *Elts;
struct radeon_dma_region indexed_verts;
struct radeon_dma_region obj;
struct radeon_dma_region rgba;
struct radeon_dma_region spec;
struct radeon_dma_region fog;
struct radeon_dma_region tex[RADEON_MAX_TEXTURE_UNITS];
struct radeon_dma_region norm;
struct radeon_dma_region indexed_verts;
struct radeon_dma_region obj;
struct radeon_dma_region rgba;
struct radeon_dma_region spec;
struct radeon_dma_region fog;
struct radeon_dma_region tex[RADEON_MAX_TEXTURE_UNITS];
struct radeon_dma_region norm;
};
/* radeon_swtcl.c
*/
struct radeon_swtcl_info {
GLuint RenderIndex;
GLuint vertex_size;
GLuint vertex_format;
GLuint RenderIndex;
GLuint vertex_size;
GLuint vertex_format;
struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
GLuint vertex_attr_count;
struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
GLuint vertex_attr_count;
GLubyte *verts;
GLubyte *verts;
/* Fallback rasterization functions
*/
radeon_point_func draw_point;
radeon_line_func draw_line;
radeon_tri_func draw_tri;
/* Fallback rasterization functions
*/
radeon_point_func draw_point;
radeon_line_func draw_line;
radeon_tri_func draw_tri;
GLuint hw_primitive;
GLenum render_primitive;
GLuint numverts;
GLuint hw_primitive;
GLenum render_primitive;
GLuint numverts;
/**
* Offset of the 4UB color data within a hardware (swtcl) vertex.
*/
GLuint coloroffset;
GLuint coloroffset;
/**
* Offset of the 3UB specular color data within a hardware (swtcl) vertex.
*/
GLuint specoffset;
GLuint specoffset;
GLboolean needproj;
GLboolean needproj;
struct radeon_dma_region indexed_verts;
struct radeon_dma_region indexed_verts;
};
struct radeon_ioctl {
GLuint vertex_offset;
GLuint vertex_size;
GLuint vertex_offset;
GLuint vertex_size;
};
#define RADEON_MAX_PRIMS 64
struct radeon_prim {
GLuint start;
GLuint end;
GLuint prim;
GLuint start;
GLuint end;
GLuint prim;
};
/* A maximum total of 20 elements per vertex: 3 floats for position, 3
@@ -615,145 +600,141 @@ struct radeon_prim {
*/
#define RADEON_MAX_VERTEX_SIZE 20
struct radeon_context {
GLcontext *glCtx; /* Mesa context */
GLcontext *glCtx; /* Mesa context */
/* Driver and hardware state management
*/
struct radeon_hw_state hw;
struct radeon_state state;
/* Driver and hardware state management
*/
struct radeon_hw_state hw;
struct radeon_state state;
/* Texture object bookkeeping
*/
unsigned nr_heaps;
driTexHeap * texture_heaps[ RADEON_NR_TEX_HEAPS ];
driTextureObject swapped;
int texture_depth;
float initialMaxAnisotropy;
/* Texture object bookkeeping
*/
unsigned nr_heaps;
driTexHeap *texture_heaps[RADEON_NR_TEX_HEAPS];
driTextureObject swapped;
int texture_depth;
float initialMaxAnisotropy;
/* Rasterization and vertex state:
*/
GLuint TclFallback;
GLuint Fallback;
GLuint NewGLState;
DECLARE_RENDERINPUTS(tnl_index_bitset); /* index of bits for last tnl_install_attrs */
/* Rasterization and vertex state:
*/
GLuint TclFallback;
GLuint Fallback;
GLuint NewGLState;
DECLARE_RENDERINPUTS(tnl_index_bitset); /* index of bits for last tnl_install_attrs */
/* Vertex buffers
*/
struct radeon_ioctl ioctl;
struct radeon_dma dma;
struct radeon_store store;
/* A full state emit as of the first state emit in the main store, in case
* the context is lost.
*/
struct radeon_store backup_store;
/* Vertex buffers
*/
struct radeon_ioctl ioctl;
struct radeon_dma dma;
struct radeon_store store;
/* A full state emit as of the first state emit in the main store, in case
* the context is lost.
*/
struct radeon_store backup_store;
/* Page flipping
*/
GLuint doPageFlip;
/* Page flipping
*/
GLuint doPageFlip;
/* Busy waiting
*/
GLuint do_usleeps;
GLuint do_irqs;
GLuint irqsEmitted;
drm_radeon_irq_wait_t iw;
/* Busy waiting
*/
GLuint do_usleeps;
GLuint do_irqs;
GLuint irqsEmitted;
drm_radeon_irq_wait_t iw;
/* Drawable, cliprect and scissor information
*/
GLuint numClipRects; /* Cliprects for the draw buffer */
drm_clip_rect_t *pClipRects;
unsigned int lastStamp;
GLboolean lost_context;
GLboolean save_on_next_emit;
radeonScreenPtr radeonScreen; /* Screen private DRI data */
drm_radeon_sarea_t *sarea; /* Private SAREA data */
/* Drawable, cliprect and scissor information
*/
GLuint numClipRects; /* Cliprects for the draw buffer */
drm_clip_rect_t *pClipRects;
unsigned int lastStamp;
GLboolean lost_context;
GLboolean save_on_next_emit;
radeonScreenPtr radeonScreen; /* Screen private DRI data */
drm_radeon_sarea_t *sarea; /* Private SAREA data */
/* TCL stuff
*/
GLmatrix TexGenMatrix[RADEON_MAX_TEXTURE_UNITS];
GLboolean recheck_texgen[RADEON_MAX_TEXTURE_UNITS];
GLboolean TexGenNeedNormals[RADEON_MAX_TEXTURE_UNITS];
GLuint TexGenEnabled;
GLuint NeedTexMatrix;
GLuint TexMatColSwap;
GLmatrix tmpmat[RADEON_MAX_TEXTURE_UNITS];
GLuint last_ReallyEnabled;
/* TCL stuff
*/
GLmatrix TexGenMatrix[RADEON_MAX_TEXTURE_UNITS];
GLboolean recheck_texgen[RADEON_MAX_TEXTURE_UNITS];
GLboolean TexGenNeedNormals[RADEON_MAX_TEXTURE_UNITS];
GLuint TexGenEnabled;
GLuint NeedTexMatrix;
GLuint TexMatColSwap;
GLmatrix tmpmat[RADEON_MAX_TEXTURE_UNITS];
GLuint last_ReallyEnabled;
/* VBI
*/
GLuint vbl_seq;
GLuint vblank_flags;
/* VBI
*/
GLuint vbl_seq;
GLuint vblank_flags;
int64_t swap_ust;
int64_t swap_missed_ust;
int64_t swap_ust;
int64_t swap_missed_ust;
GLuint swap_count;
GLuint swap_missed_count;
GLuint swap_count;
GLuint swap_missed_count;
/* radeon_tcl.c
*/
struct radeon_tcl_info tcl;
/* radeon_tcl.c
*/
struct radeon_tcl_info tcl;
/* radeon_swtcl.c
*/
struct radeon_swtcl_info swtcl;
/* radeon_swtcl.c
*/
struct radeon_swtcl_info swtcl;
/* Mirrors of some DRI state
*/
struct radeon_dri_mirror dri;
/* Mirrors of some DRI state
*/
struct radeon_dri_mirror dri;
/* Configuration cache
*/
driOptionCache optionCache;
/* Configuration cache
*/
driOptionCache optionCache;
GLboolean using_hyperz;
GLboolean texmicrotile;
GLboolean using_hyperz;
GLboolean texmicrotile;
/* Performance counters
*/
GLuint boxes; /* Draw performance boxes */
GLuint hardwareWentIdle;
GLuint c_clears;
GLuint c_drawWaits;
GLuint c_textureSwaps;
GLuint c_textureBytes;
GLuint c_vertexBuffers;
/* Performance counters
*/
GLuint boxes; /* Draw performance boxes */
GLuint hardwareWentIdle;
GLuint c_clears;
GLuint c_drawWaits;
GLuint c_textureSwaps;
GLuint c_textureBytes;
GLuint c_vertexBuffers;
};
#define RADEON_CONTEXT(ctx) ((radeonContextPtr)(ctx->DriverCtx))
static __inline GLuint radeonPackColor( GLuint cpp,
GLubyte r, GLubyte g,
GLubyte b, GLubyte a )
static __inline GLuint radeonPackColor(GLuint cpp,
GLubyte r, GLubyte g,
GLubyte b, GLubyte a)
{
switch ( cpp ) {
case 2:
return PACK_COLOR_565( r, g, b );
case 4:
return PACK_COLOR_8888( a, r, g, b );
default:
return 0;
}
switch (cpp) {
case 2:
return PACK_COLOR_565(r, g, b);
case 4:
return PACK_COLOR_8888(a, r, g, b);
default:
return 0;
}
}
#define RADEON_OLD_PACKETS 1
extern void radeonDestroyContext( __DRIcontextPrivate *driContextPriv );
extern GLboolean radeonCreateContext(const __GLcontextModes *glVisual,
__DRIcontextPrivate *driContextPriv,
extern void radeonDestroyContext(__DRIcontextPrivate * driContextPriv);
extern GLboolean radeonCreateContext(const __GLcontextModes * glVisual,
__DRIcontextPrivate * driContextPriv,
void *sharedContextPrivate);
extern void radeonSwapBuffers( __DRIdrawablePrivate *dPriv );
extern void radeonSwapBuffers(__DRIdrawablePrivate * dPriv);
extern void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv,
int x, int y, int w, int h);
extern GLboolean radeonMakeCurrent( __DRIcontextPrivate *driContextPriv,
__DRIdrawablePrivate *driDrawPriv,
__DRIdrawablePrivate *driReadPriv );
extern GLboolean radeonUnbindContext( __DRIcontextPrivate *driContextPriv );
extern GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv,
__DRIdrawablePrivate * driDrawPriv,
__DRIdrawablePrivate * driReadPriv);
extern GLboolean radeonUnbindContext(__DRIcontextPrivate * driContextPriv);
/* ================================================================
* Debugging:
@@ -766,18 +747,18 @@ extern int RADEON_DEBUG;
#define RADEON_DEBUG 0
#endif
#define DEBUG_TEXTURE 0x001
#define DEBUG_STATE 0x002
#define DEBUG_IOCTL 0x004
#define DEBUG_PRIMS 0x008
#define DEBUG_VERTS 0x010
#define DEBUG_FALLBACKS 0x020
#define DEBUG_VFMT 0x040
#define DEBUG_CODEGEN 0x080
#define DEBUG_VERBOSE 0x100
#define DEBUG_DRI 0x200
#define DEBUG_DMA 0x400
#define DEBUG_SANITY 0x800
#define DEBUG_SYNC 0x1000
#define DEBUG_TEXTURE 0x0001
#define DEBUG_STATE 0x0002
#define DEBUG_IOCTL 0x0004
#define DEBUG_PRIMS 0x0008
#define DEBUG_VERTS 0x0010
#define DEBUG_FALLBACKS 0x0020
#define DEBUG_VFMT 0x0040
#define DEBUG_CODEGEN 0x0080
#define DEBUG_VERBOSE 0x0100
#define DEBUG_DRI 0x0200
#define DEBUG_DMA 0x0400
#define DEBUG_SANITY 0x0800
#define DEBUG_SYNC 0x1000
#endif /* __RADEON_CONTEXT_H__ */
#endif /* __RADEON_CONTEXT_H__ */

View File

@@ -1,8 +1,12 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_lock.c,v 1.5 2002/10/30 12:51:55 alanh Exp $ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
VA Linux Systems Inc., Fremont, California.
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
initial release of the Radeon 8500 driver under the XFree86 license.
This notice must be preserved.
All Rights Reserved.
@@ -30,8 +34,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
* Kevin E. Martin <martin@valinux.com>
* Gareth Hughes <gareth@valinux.com>
* Keith Whitwell <keith@tungstengraphics.com>
* Kevin E. Martin <martin@valinux.com>
*/
#include "glheader.h"
@@ -44,7 +49,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "drirenderbuffer.h"
#if DEBUG_LOCKING
char *prevLockFile = NULL;
int prevLockLine = 0;
@@ -52,17 +56,15 @@ int prevLockLine = 0;
/* Turn on/off page flipping according to the flags in the sarea:
*/
static void
radeonUpdatePageFlipping( radeonContextPtr rmesa )
static void radeonUpdatePageFlipping(radeonContextPtr rmesa)
{
rmesa->doPageFlip = rmesa->sarea->pfState;
if (rmesa->glCtx->WinSysDrawBuffer) {
driFlipRenderbuffers(rmesa->glCtx->WinSysDrawBuffer,
rmesa->sarea->pfCurrentPage);
}
rmesa->doPageFlip = rmesa->sarea->pfState;
if (rmesa->glCtx->WinSysDrawBuffer) {
driFlipRenderbuffers(rmesa->glCtx->WinSysDrawBuffer,
rmesa->sarea->pfCurrentPage);
}
}
/* Update the hardware state. This is called if another context has
* grabbed the hardware lock, which includes the X server. This
* function also updates the driver's window state after the X server
@@ -71,51 +73,52 @@ radeonUpdatePageFlipping( radeonContextPtr rmesa )
* the hardware lock when it changes the window state, this routine will
* automatically be called after such a change.
*/
void radeonGetLock( radeonContextPtr rmesa, GLuint flags )
void radeonGetLock(radeonContextPtr rmesa, GLuint flags)
{
__DRIdrawablePrivate *const drawable = rmesa->dri.drawable;
__DRIdrawablePrivate *const readable = rmesa->dri.readable;
__DRIscreenPrivate *sPriv = rmesa->dri.screen;
drm_radeon_sarea_t *sarea = rmesa->sarea;
__DRIdrawablePrivate *const drawable = rmesa->dri.drawable;
__DRIdrawablePrivate *const readable = rmesa->dri.readable;
__DRIscreenPrivate *sPriv = rmesa->dri.screen;
drm_radeon_sarea_t *sarea = rmesa->sarea;
drmGetLock( rmesa->dri.fd, rmesa->dri.hwContext, flags );
drmGetLock(rmesa->dri.fd, rmesa->dri.hwContext, flags);
/* The window might have moved, so we might need to get new clip
* rects.
*
* NOTE: This releases and regrabs the hw lock to allow the X server
* to respond to the DRI protocol request for new drawable info.
* Since the hardware state depends on having the latest drawable
* clip rects, all state checking must be done _after_ this call.
*/
DRI_VALIDATE_DRAWABLE_INFO( sPriv, drawable );
if (drawable != readable) {
DRI_VALIDATE_DRAWABLE_INFO( sPriv, readable );
}
/* The window might have moved, so we might need to get new clip
* rects.
*
* NOTE: This releases and regrabs the hw lock to allow the X server
* to respond to the DRI protocol request for new drawable info.
* Since the hardware state depends on having the latest drawable
* clip rects, all state checking must be done _after_ this call.
*/
DRI_VALIDATE_DRAWABLE_INFO(sPriv, drawable);
if (drawable != readable) {
DRI_VALIDATE_DRAWABLE_INFO(sPriv, readable);
}
if ( rmesa->lastStamp != drawable->lastStamp ) {
radeonUpdatePageFlipping( rmesa );
radeonSetCliprects( rmesa );
radeonUpdateViewportOffset( rmesa->glCtx );
driUpdateFramebufferSize(rmesa->glCtx, drawable);
}
if (rmesa->lastStamp != drawable->lastStamp) {
radeonUpdatePageFlipping(rmesa);
radeonSetCliprects(rmesa);
radeonUpdateViewportOffset(rmesa->glCtx);
driUpdateFramebufferSize(rmesa->glCtx, drawable);
}
RADEON_STATECHANGE( rmesa, ctx );
if (rmesa->sarea->tiling_enabled) {
rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= RADEON_COLOR_TILE_ENABLE;
}
else {
rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] &= ~RADEON_COLOR_TILE_ENABLE;
}
RADEON_STATECHANGE(rmesa, ctx);
if (rmesa->sarea->tiling_enabled) {
rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |=
RADEON_COLOR_TILE_ENABLE;
} else {
rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] &=
~RADEON_COLOR_TILE_ENABLE;
}
if ( sarea->ctx_owner != rmesa->dri.hwContext ) {
int i;
sarea->ctx_owner = rmesa->dri.hwContext;
if (sarea->ctx_owner != rmesa->dri.hwContext) {
int i;
sarea->ctx_owner = rmesa->dri.hwContext;
for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
DRI_AGE_TEXTURES( rmesa->texture_heaps[ i ] );
}
}
for (i = 0; i < rmesa->nr_heaps; i++) {
DRI_AGE_TEXTURES(rmesa->texture_heaps[i]);
}
}
rmesa->lost_context = GL_TRUE;
rmesa->lost_context = GL_TRUE;
}

View File

@@ -1,8 +1,12 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_lock.h,v 1.3 2002/10/30 12:51:55 alanh Exp $ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
VA Linux Systems Inc., Fremont, California.
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
initial release of the Radeon 8500 driver under the XFree86 license.
This notice must be preserved.
All Rights Reserved.
@@ -30,14 +34,15 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
* Kevin E. Martin <martin@valinux.com>
* Gareth Hughes <gareth@valinux.com>
* Keith Whitwell <keith@tungstengraphics.com>
* Kevin E. Martin <martin@valinux.com>
*/
#ifndef __RADEON_LOCK_H__
#define __RADEON_LOCK_H__
extern void radeonGetLock( radeonContextPtr rmesa, GLuint flags );
extern void radeonGetLock(radeonContextPtr rmesa, GLuint flags);
/* Turn DEBUG_LOCKING on to find locking conflicts.
*/
@@ -83,26 +88,25 @@ extern int prevLockLine;
* do not do any drawing !!!
*/
/* Lock the hardware and validate our state.
*/
#define LOCK_HARDWARE( rmesa ) \
do { \
char __ret = 0; \
DEBUG_CHECK_LOCK(); \
DRM_CAS( rmesa->dri.hwLock, rmesa->dri.hwContext, \
(DRM_LOCK_HELD | rmesa->dri.hwContext), __ret ); \
DRM_CAS( (rmesa)->dri.hwLock, (rmesa)->dri.hwContext, \
(DRM_LOCK_HELD | (rmesa)->dri.hwContext), __ret ); \
if ( __ret ) \
radeonGetLock( rmesa, 0 ); \
radeonGetLock( (rmesa), 0 ); \
DEBUG_LOCK(); \
} while (0)
#define UNLOCK_HARDWARE( rmesa ) \
do { \
DRM_UNLOCK( rmesa->dri.fd, \
rmesa->dri.hwLock, \
rmesa->dri.hwContext ); \
DRM_UNLOCK( (rmesa)->dri.fd, \
(rmesa)->dri.hwLock, \
(rmesa)->dri.hwContext ); \
DEBUG_RESET(); \
} while (0)
#endif /* __RADEON_LOCK_H__ */
#endif /* __RADEON_LOCK_H__ */

View File

@@ -656,8 +656,7 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv )
case PCI_CHIP_RC410_5A61:
case PCI_CHIP_RC410_5A62:
screen->chip_family = CHIP_FAMILY_RS400;
fprintf(stderr, "Warning, xpress200 detected. Won't work.\n");
return NULL;
fprintf(stderr, "Warning, xpress200 detected.\n");
break;
default:

View File

@@ -1,9 +1,13 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_span.c,v 1.6 2002/10/30 12:51:56 alanh Exp $ */
/**************************************************************************
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
VA Linux Systems Inc., Fremont, California.
The Weather Channel (TM) funded Tungsten Graphics to develop the
initial release of the Radeon 8500 driver under the XFree86 license.
This notice must be preserved.
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining
@@ -47,10 +51,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "drirenderbuffer.h"
#define DBG 0
/*
* Note that all information needed to access pixels in a renderbuffer
* should be obtained through the gl_renderbuffer parameter, not per-context
@@ -81,8 +83,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define HW_UNLOCK()
/* ================================================================
* Color buffer
*/
@@ -97,7 +97,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define GET_PTR(X,Y) (buf + ((Y) * drb->flippedPitch + (X)) * 2)
#include "spantmp2.h"
/* 32 bit, ARGB8888 color spanline and pixel functions
*/
#define SPANTMP_PIXEL_FMT GL_BGRA
@@ -108,7 +107,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define GET_PTR(X,Y) (buf + ((Y) * drb->flippedPitch + (X)) * 4)
#include "spantmp2.h"
/* ================================================================
* Depth buffer
*/
@@ -123,59 +121,56 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* too...
*/
static GLuint
radeon_mba_z32( const driRenderbuffer *drb, GLint x, GLint y )
static GLuint radeon_mba_z32(const driRenderbuffer * drb, GLint x, GLint y)
{
GLuint pitch = drb->pitch;
if (drb->depthHasSurface) {
return 4 * (x + y * pitch);
}
else {
GLuint ba, address = 0; /* a[0..1] = 0 */
GLuint pitch = drb->pitch;
if (drb->depthHasSurface) {
return 4 * (x + y * pitch);
} else {
GLuint ba, address = 0; /* a[0..1] = 0 */
ba = (y / 16) * (pitch / 16) + (x / 16);
#ifdef COMPILE_R300
ba = (y / 8) * (pitch / 8) + (x / 8);
#else
ba = (y / 16) * (pitch / 16) + (x / 16);
#endif
address |= (x & 0x7) << 2; /* a[2..4] = x[0..2] */
address |= (y & 0x3) << 5; /* a[5..6] = y[0..1] */
address |=
(((x & 0x10) >> 2) ^ (y & 0x4)) << 5; /* a[7] = x[4] ^ y[2] */
address |= (ba & 0x3) << 8; /* a[8..9] = ba[0..1] */
address |= (x & 0x7) << 2; /* a[2..4] = x[0..2] */
address |= (y & 0x3) << 5; /* a[5..6] = y[0..1] */
address |= (((x & 0x10) >> 2) ^ (y & 0x4)) << 5; /* a[7] = x[4] ^ y[2] */
address |= (ba & 0x3) << 8; /* a[8..9] = ba[0..1] */
address |= (y & 0x8) << 7; /* a[10] = y[3] */
address |=
(((x & 0x8) << 1) ^ (y & 0x10)) << 7; /* a[11] = x[3] ^ y[4] */
address |= (ba & ~0x3) << 10; /* a[12..] = ba[2..] */
address |= (y & 0x8) << 7; /* a[10] = y[3] */
address |= (((x & 0x8) << 1) ^ (y & 0x10)) << 7; /* a[11] = x[3] ^ y[4] */
address |= (ba & ~0x3) << 10; /* a[12..] = ba[2..] */
return address;
}
return address;
}
}
static INLINE GLuint
radeon_mba_z16( const driRenderbuffer *drb, GLint x, GLint y )
radeon_mba_z16(const driRenderbuffer * drb, GLint x, GLint y)
{
GLuint pitch = drb->pitch;
if (drb->depthHasSurface) {
return 2 * (x + y * pitch);
}
else {
GLuint ba, address = 0; /* a[0] = 0 */
GLuint pitch = drb->pitch;
if (drb->depthHasSurface) {
return 2 * (x + y * pitch);
} else {
GLuint ba, address = 0; /* a[0] = 0 */
ba = (y / 16) * (pitch / 32) + (x / 32);
ba = (y / 16) * (pitch / 32) + (x / 32);
address |= (x & 0x7) << 1; /* a[1..3] = x[0..2] */
address |= (y & 0x7) << 4; /* a[4..6] = y[0..2] */
address |= (x & 0x8) << 4; /* a[7] = x[3] */
address |= (ba & 0x3) << 8; /* a[8..9] = ba[0..1] */
address |= (y & 0x8) << 7; /* a[10] = y[3] */
address |= ((x & 0x10) ^ (y & 0x10)) << 7;/* a[11] = x[4] ^ y[4] */
address |= (ba & ~0x3) << 10; /* a[12..] = ba[2..] */
address |= (x & 0x7) << 1; /* a[1..3] = x[0..2] */
address |= (y & 0x7) << 4; /* a[4..6] = y[0..2] */
address |= (x & 0x8) << 4; /* a[7] = x[3] */
address |= (ba & 0x3) << 8; /* a[8..9] = ba[0..1] */
address |= (y & 0x8) << 7; /* a[10] = y[3] */
address |= ((x & 0x10) ^ (y & 0x10)) << 7; /* a[11] = x[4] ^ y[4] */
address |= (ba & ~0x3) << 10; /* a[12..] = ba[2..] */
return address;
}
return address;
}
}
/* 16-bit depth buffer functions
*/
#define WRITE_DEPTH( _x, _y, d ) \
@@ -187,9 +182,21 @@ radeon_mba_z16( const driRenderbuffer *drb, GLint x, GLint y )
#define TAG(x) radeon##x##_z16
#include "depthtmp.h"
/* 24 bit depth, 8 bit stencil depthbuffer functions
*
* Careful: It looks like the R300 uses ZZZS byte order while the R200
* uses SZZZ for 24 bit depth, 8 bit stencil mode.
*/
#ifdef COMPILE_R300
#define WRITE_DEPTH( _x, _y, d ) \
do { \
GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo ); \
GLuint tmp = *(GLuint *)(buf + offset); \
tmp &= 0x000000ff; \
tmp |= ((d << 8) & 0xffffff00); \
*(GLuint *)(buf + offset) = tmp; \
} while (0)
#else
#define WRITE_DEPTH( _x, _y, d ) \
do { \
GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo ); \
@@ -198,21 +205,39 @@ do { \
tmp |= ((d) & 0x00ffffff); \
*(GLuint *)(buf + offset) = tmp; \
} while (0)
#endif
#ifdef COMPILE_R300
#define READ_DEPTH( d, _x, _y ) \
do { \
d = (*(GLuint *)(buf + radeon_mba_z32( drb, _x + xo, \
_y + yo )) & 0xffffff00) >> 8; \
}while(0)
#else
#define READ_DEPTH( d, _x, _y ) \
d = *(GLuint *)(buf + radeon_mba_z32( drb, _x + xo, \
_y + yo )) & 0x00ffffff;
#endif
#define TAG(x) radeon##x##_z24_s8
#include "depthtmp.h"
/* ================================================================
* Stencil buffer
*/
/* 24 bit depth, 8 bit stencil depthbuffer functions
*/
#ifdef COMPILE_R300
#define WRITE_STENCIL( _x, _y, d ) \
do { \
GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo ); \
GLuint tmp = *(GLuint *)(buf + offset); \
tmp &= 0xffffff00; \
tmp |= (d) & 0xff; \
*(GLuint *)(buf + offset) = tmp; \
} while (0)
#else
#define WRITE_STENCIL( _x, _y, d ) \
do { \
GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo ); \
@@ -221,69 +246,77 @@ do { \
tmp |= (((d) & 0xff) << 24); \
*(GLuint *)(buf + offset) = tmp; \
} while (0)
#endif
#ifdef COMPILE_R300
#define READ_STENCIL( d, _x, _y ) \
do { \
GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo ); \
GLuint tmp = *(GLuint *)(buf + offset); \
tmp &= 0xff000000; \
d = tmp >> 24; \
d = tmp & 0x000000ff; \
} while (0)
#else
#define READ_STENCIL( d, _x, _y ) \
do { \
GLuint offset = radeon_mba_z32( drb, _x + xo, _y + yo ); \
GLuint tmp = *(GLuint *)(buf + offset); \
d = (tmp & 0xff000000) >> 24; \
} while (0)
#endif
#define TAG(x) radeon##x##_z24_s8
#include "stenciltmp.h"
/* Move locking out to get reasonable span performance (10x better
* than doing this in HW_LOCK above). WaitForIdle() is the main
* culprit.
*/
static void radeonSpanRenderStart( GLcontext *ctx )
static void radeonSpanRenderStart(GLcontext * ctx)
{
radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
RADEON_FIREVERTICES( rmesa );
LOCK_HARDWARE( rmesa );
radeonWaitForIdleLocked( rmesa );
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
#ifdef COMPILE_R300
r300ContextPtr r300 = (r300ContextPtr) rmesa;
R300_FIREVERTICES(r300);
#else
RADEON_FIREVERTICES(rmesa);
#endif
LOCK_HARDWARE(rmesa);
radeonWaitForIdleLocked(rmesa);
}
static void radeonSpanRenderFinish( GLcontext *ctx )
static void radeonSpanRenderFinish(GLcontext * ctx)
{
radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
_swrast_flush( ctx );
UNLOCK_HARDWARE( rmesa );
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
_swrast_flush(ctx);
UNLOCK_HARDWARE(rmesa);
}
void radeonInitSpanFuncs( GLcontext *ctx )
void radeonInitSpanFuncs(GLcontext * ctx)
{
struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
swdd->SpanRenderStart = radeonSpanRenderStart;
swdd->SpanRenderFinish = radeonSpanRenderFinish;
struct swrast_device_driver *swdd =
_swrast_GetDeviceDriverReference(ctx);
swdd->SpanRenderStart = radeonSpanRenderStart;
swdd->SpanRenderFinish = radeonSpanRenderFinish;
}
/**
* Plug in the Get/Put routines for the given driRenderbuffer.
*/
void
radeonSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
void radeonSetSpanFunctions(driRenderbuffer * drb, const GLvisual * vis)
{
if (drb->Base.InternalFormat == GL_RGBA) {
if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
radeonInitPointers_RGB565(&drb->Base);
}
else {
radeonInitPointers_ARGB8888(&drb->Base);
}
}
else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
radeonInitDepthPointers_z16(&drb->Base);
}
else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
radeonInitDepthPointers_z24_s8(&drb->Base);
}
else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
radeonInitStencilPointers_z24_s8(&drb->Base);
}
if (drb->Base.InternalFormat == GL_RGBA) {
if (vis->redBits == 5 && vis->greenBits == 6
&& vis->blueBits == 5) {
radeonInitPointers_RGB565(&drb->Base);
} else {
radeonInitPointers_ARGB8888(&drb->Base);
}
} else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
radeonInitDepthPointers_z16(&drb->Base);
} else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
radeonInitDepthPointers_z24_s8(&drb->Base);
} else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
radeonInitStencilPointers_z24_s8(&drb->Base);
}
}

View File

@@ -1,8 +1,12 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_span.h,v 1.2 2002/02/22 21:45:01 dawes Exp $ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
VA Linux Systems Inc., Fremont, California.
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
initial release of the Radeon 8500 driver under the XFree86 license.
This notice must be preserved.
All Rights Reserved.
@@ -30,8 +34,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
* Kevin E. Martin <martin@valinux.com>
* Gareth Hughes <gareth@valinux.com>
* Keith Whitwell <keith@tungstengraphics.com>
* Kevin E. Martin <martin@valinux.com>
*/
#ifndef __RADEON_SPAN_H__
@@ -39,8 +44,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "drirenderbuffer.h"
extern void radeonInitSpanFuncs( GLcontext *ctx );
extern void radeonSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
extern void radeonInitSpanFuncs(GLcontext * ctx);
extern void radeonSetSpanFunctions(driRenderbuffer * rb, const GLvisual * vis);
#endif

View File

@@ -141,7 +141,7 @@ static void
SetCurrentContext(GLXContext c)
{
#if defined(GLX_USE_TLS)
CurrentContext = context;
CurrentContext = c;
#elif defined(THREADS)
_glthread_SetTSD(&ContextTSD, c);
#else

View File

@@ -438,7 +438,7 @@ xmesa_DrawPixels_8R8G8B( GLcontext *ctx,
{
const SWcontext *swrast = SWRAST_CONTEXT( ctx );
struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];
struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb->Wrapped;
struct xmesa_renderbuffer *xrb = xmesa_renderbuffer(rb->Wrapped);
if (swrast->NewState)
_swrast_validate_derived( ctx );
@@ -546,7 +546,7 @@ xmesa_DrawPixels_5R6G5B( GLcontext *ctx,
const GLvoid *pixels )
{
struct xmesa_renderbuffer *xrb
= (struct xmesa_renderbuffer *) ctx->DrawBuffer->_ColorDrawBuffers[0][0];
= xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped);
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const SWcontext *swrast = SWRAST_CONTEXT( ctx );
XMesaDisplay *dpy = xmesa->xm_visual->display;
@@ -652,10 +652,10 @@ xmesa_CopyPixels( GLcontext *ctx,
const SWcontext *swrast = SWRAST_CONTEXT( ctx );
XMesaDisplay *dpy = xmesa->xm_visual->display;
const XMesaGC gc = ((XMesaBuffer) ctx->DrawBuffer)->gc;
struct xmesa_renderbuffer *srcXrb = (struct xmesa_renderbuffer *)
ctx->ReadBuffer->_ColorReadBuffer;
struct xmesa_renderbuffer *dstXrb = (struct xmesa_renderbuffer *)
ctx->DrawBuffer->_ColorDrawBuffers[0][0];
struct xmesa_renderbuffer *srcXrb
= xmesa_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer->Wrapped);
struct xmesa_renderbuffer *dstXrb
= xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped);
ASSERT(dpy);
ASSERT(gc);

View File

@@ -82,12 +82,18 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print ''
print '#ifdef GLX_USE_TLS'
print ''
print '#ifdef GLX_X86_READONLY_TEXT'
print '# define CTX_INSNS MOV_L(GS:(EAX), EAX)'
print '#else'
print '# define CTX_INSNS NOP /* Pad for init_glapi_relocs() */'
print '#endif'
print ''
print '# define GL_STUB(fn,off,fn_alt)\t\t\t\\'
print 'ALIGNTEXT16;\t\t\t\t\t\t\\'
print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\'
print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\'
print '\tCALL(_x86_get_dispatch) ;\t\t\t\\'
print '\tNOP ;\t\t\t\t\t\t\\'
print '\tCTX_INSNS ; \\'
print '\tJMP(GL_OFFSET(off))'
print ''
print '#elif defined(PTHREADS)'
@@ -138,7 +144,10 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print '\tHIDDEN(GLNAME(_x86_get_dispatch))'
print 'ALIGNTEXT16'
print 'GLNAME(_x86_get_dispatch):'
print '\tmovl\t%gs:_glapi_tls_Dispatch@NTPOFF, %eax'
print '\tcall 1f'
print '1:\tpopl %eax'
print '\taddl $_GLOBAL_OFFSET_TABLE_+[.-1b], %eax'
print '\tmovl _glapi_tls_Dispatch@GOTNTPOFF(%eax), %eax'
print '\tret'
print ''
print '#elif defined(PTHREADS)'
@@ -158,7 +167,7 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print '#endif'
print ''
print '#if defined( GLX_USE_TLS )'
print '#if defined( GLX_USE_TLS ) && !defined( GLX_X86_READONLY_TEXT )'
print '\t\t.section\twtext, "awx", @progbits'
print '#endif /* defined( GLX_USE_TLS ) */'

View File

@@ -1028,22 +1028,24 @@ _glapi_check_table(const struct _glapi_table *table)
#if defined(PTHREADS) || defined(GLX_USE_TLS)
/**
* Perform platform-specific GL API entry-point fixups.
*
*
*/
static void
init_glapi_relocs( void )
{
#if defined( USE_X86_ASM ) && defined( GLX_USE_TLS )
extern void * _x86_get_dispatch(void);
const GLubyte * const get_disp = (const GLubyte *) _x86_get_dispatch;
#if defined(USE_X86_ASM) && defined(GLX_USE_TLS) && !defined(GLX_X86_READONLY_TEXT)
extern unsigned long _x86_get_dispatch(void);
char run_time_patch[] = {
0x65, 0xa1, 0, 0, 0, 0 /* movl %gs:0,%eax */
};
GLuint *offset = (GLuint *) &run_time_patch[2]; /* 32-bits for x86/32 */
const GLubyte * const get_disp = (const GLubyte *) run_time_patch;
GLubyte * curr_func = (GLubyte *) gl_dispatch_functions_start;
*offset = _x86_get_dispatch();
while ( curr_func != (GLubyte *) gl_dispatch_functions_end ) {
(void) memcpy( curr_func, get_disp, 6 );
(void) memcpy( curr_func, get_disp, sizeof(run_time_patch));
curr_func += DISPATCH_FUNCTION_SIZE;
}
#endif /* defined( USE_X86_ASM ) && defined( GLX_USE_TLS ) */
}
#endif
}
#endif /* defined(PTHREADS) || defined(GLX_USE_TLS) */

View File

@@ -764,6 +764,7 @@ pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib)
_mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, obj->MagFilter);
_mesa_TexParameterf(target, GL_TEXTURE_MIN_LOD, obj->MinLod);
_mesa_TexParameterf(target, GL_TEXTURE_MAX_LOD, obj->MaxLod);
_mesa_TexParameterf(target, GL_TEXTURE_LOD_BIAS, obj->LodBias);
_mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, obj->BaseLevel);
if (target != GL_TEXTURE_RECTANGLE_ARB)
_mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, obj->MaxLevel);

View File

@@ -5,9 +5,9 @@
/*
* Mesa 3-D graphics library
* Version: 6.5.2
* Version: 7.0
*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2007 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"),
@@ -240,10 +240,7 @@
/**
* Bits per depth buffer value.
*
* Any reasonable value up to 31 will work. 32 doesn't work because of integer
* overflow problems in the rasterizer code.
* Bits per depth buffer value (max is 32).
*/
#ifndef DEFAULT_SOFTWARE_DEPTH_BITS
#define DEFAULT_SOFTWARE_DEPTH_BITS 16

View File

@@ -6,9 +6,9 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Version: 7.0
*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2007 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"),
@@ -1382,8 +1382,11 @@ check_compatible(const GLcontext *ctx, const GLframebuffer *buffer)
return GL_FALSE;
if (ctxvis->blueMask && ctxvis->blueMask != bufvis->blueMask)
return GL_FALSE;
#if 0
/* disabled (see bug 11161) */
if (ctxvis->depthBits && ctxvis->depthBits != bufvis->depthBits)
return GL_FALSE;
#endif
if (ctxvis->stencilBits && ctxvis->stencilBits != bufvis->stencilBits)
return GL_FALSE;

View File

@@ -190,6 +190,25 @@ _mesa_DisableClientState( GLenum cap )
}
/**
* Helper function to enable or disable a texture target.
*/
static GLboolean
enable_texture(GLcontext *ctx, GLboolean state, GLbitfield bit)
{
const GLuint curr = ctx->Texture.CurrentUnit;
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
const GLuint newenabled = (!state)
? (texUnit->Enabled & ~bit) : (texUnit->Enabled | bit);
if (!ctx->DrawBuffer->Visual.rgbMode || texUnit->Enabled == newenabled)
return GL_FALSE;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texUnit->Enabled = newenabled;
return GL_TRUE;
}
/**
* Helper function to enable or disable state.
@@ -558,45 +577,21 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state)
FLUSH_VERTICES(ctx, _NEW_STENCIL);
ctx->Stencil.Enabled = state;
break;
case GL_TEXTURE_1D: {
const GLuint curr = ctx->Texture.CurrentUnit;
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
GLuint newenabled = texUnit->Enabled & ~TEXTURE_1D_BIT;
if (state)
newenabled |= TEXTURE_1D_BIT;
if (!ctx->DrawBuffer->Visual.rgbMode
|| texUnit->Enabled == newenabled)
case GL_TEXTURE_1D:
if (!enable_texture(ctx, state, TEXTURE_1D_BIT)) {
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texUnit->Enabled = newenabled;
}
break;
}
case GL_TEXTURE_2D: {
const GLuint curr = ctx->Texture.CurrentUnit;
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
GLuint newenabled = texUnit->Enabled & ~TEXTURE_2D_BIT;
if (state)
newenabled |= TEXTURE_2D_BIT;
if (!ctx->DrawBuffer->Visual.rgbMode
|| texUnit->Enabled == newenabled)
case GL_TEXTURE_2D:
if (!enable_texture(ctx, state, TEXTURE_2D_BIT)) {
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texUnit->Enabled = newenabled;
}
break;
}
case GL_TEXTURE_3D: {
const GLuint curr = ctx->Texture.CurrentUnit;
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
GLuint newenabled = texUnit->Enabled & ~TEXTURE_3D_BIT;
if (state)
newenabled |= TEXTURE_3D_BIT;
if (!ctx->DrawBuffer->Visual.rgbMode
|| texUnit->Enabled == newenabled)
case GL_TEXTURE_3D:
if (!enable_texture(ctx, state, TEXTURE_3D_BIT)) {
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texUnit->Enabled = newenabled;
}
break;
}
case GL_TEXTURE_GEN_Q: {
GLuint unit = ctx->Texture.CurrentUnit;
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
@@ -715,18 +710,9 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state)
/* GL_ARB_texture_cube_map */
case GL_TEXTURE_CUBE_MAP_ARB:
{
const GLuint curr = ctx->Texture.CurrentUnit;
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
GLuint newenabled = texUnit->Enabled & ~TEXTURE_CUBE_BIT;
CHECK_EXTENSION(ARB_texture_cube_map, cap);
if (state)
newenabled |= TEXTURE_CUBE_BIT;
if (!ctx->DrawBuffer->Visual.rgbMode
|| texUnit->Enabled == newenabled)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texUnit->Enabled = newenabled;
CHECK_EXTENSION(ARB_texture_cube_map, cap);
if (!enable_texture(ctx, state, TEXTURE_CUBE_BIT)) {
return;
}
break;
@@ -879,18 +865,8 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state)
/* GL_NV_texture_rectangle */
case GL_TEXTURE_RECTANGLE_NV:
CHECK_EXTENSION(NV_texture_rectangle, cap);
{
const GLuint curr = ctx->Texture.CurrentUnit;
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
GLuint newenabled = texUnit->Enabled & ~TEXTURE_RECT_BIT;
CHECK_EXTENSION(NV_texture_rectangle, cap);
if (state)
newenabled |= TEXTURE_RECT_BIT;
if (!ctx->DrawBuffer->Visual.rgbMode
|| texUnit->Enabled == newenabled)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texUnit->Enabled = newenabled;
if (!enable_texture(ctx, state, TEXTURE_RECT_BIT)) {
return;
}
break;
@@ -1001,6 +977,18 @@ _mesa_Disable( GLenum cap )
}
/**
* Helper function to determine whether a texture target is enabled.
*/
static GLboolean
is_texture_enabled(GLcontext *ctx, GLbitfield bit)
{
const struct gl_texture_unit *const texUnit =
&ctx->Texture.Unit[ctx->Texture.CurrentUnit];
return (texUnit->Enabled & bit) ? GL_TRUE : GL_FALSE;
}
/**
* Return simple enable/disable state.
*
@@ -1117,23 +1105,11 @@ _mesa_IsEnabled( GLenum cap )
case GL_STENCIL_TEST:
return ctx->Stencil.Enabled;
case GL_TEXTURE_1D:
{
const struct gl_texture_unit *texUnit;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
return (texUnit->Enabled & TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE;
}
return is_texture_enabled(ctx, TEXTURE_1D_BIT);
case GL_TEXTURE_2D:
{
const struct gl_texture_unit *texUnit;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
return (texUnit->Enabled & TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE;
}
return is_texture_enabled(ctx, TEXTURE_2D_BIT);
case GL_TEXTURE_3D:
{
const struct gl_texture_unit *texUnit;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
return (texUnit->Enabled & TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE;
}
return is_texture_enabled(ctx, TEXTURE_3D_BIT);
case GL_TEXTURE_GEN_Q:
{
const struct gl_texture_unit *texUnit;
@@ -1219,11 +1195,7 @@ _mesa_IsEnabled( GLenum cap )
/* GL_ARB_texture_cube_map */
case GL_TEXTURE_CUBE_MAP_ARB:
CHECK_EXTENSION(ARB_texture_cube_map);
{
const struct gl_texture_unit *texUnit;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
return (texUnit->Enabled & TEXTURE_CUBE_BIT) ? GL_TRUE : GL_FALSE;
}
return is_texture_enabled(ctx, TEXTURE_CUBE_BIT);
/* GL_EXT_secondary_color */
case GL_COLOR_SUM_EXT:
@@ -1343,11 +1315,7 @@ _mesa_IsEnabled( GLenum cap )
/* GL_NV_texture_rectangle */
case GL_TEXTURE_RECTANGLE_NV:
CHECK_EXTENSION(NV_texture_rectangle);
{
const struct gl_texture_unit *texUnit;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
return (texUnit->Enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE;
}
return is_texture_enabled(ctx, TEXTURE_RECT_BIT);
/* GL_EXT_stencil_two_side */
case GL_STENCIL_TEST_TWO_SIDE_EXT:

View File

@@ -1144,20 +1144,19 @@ _mesa_CheckFramebufferStatusEXT(GLenum target)
* Common code called by glFramebufferTexture1D/2D/3DEXT().
*/
static void
framebuffer_texture(GLuint dims, GLenum target, GLenum attachment,
GLenum textarget, GLuint texture,
framebuffer_texture(GLcontext *ctx, const char *caller, GLenum target,
GLenum attachment, GLenum textarget, GLuint texture,
GLint level, GLint zoffset)
{
struct gl_renderbuffer_attachment *att;
struct gl_texture_object *texObj = NULL;
struct gl_framebuffer *fb;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (target != GL_FRAMEBUFFER_EXT) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glFramebufferTexture%dDEXT(target)", dims);
"glFramebufferTexture%sEXT(target)", caller);
return;
}
@@ -1167,83 +1166,53 @@ framebuffer_texture(GLuint dims, GLenum target, GLenum attachment,
/* check framebuffer binding */
if (fb->Name == 0) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glFramebufferTexture%dDEXT", dims);
"glFramebufferTexture%sEXT", caller);
return;
}
if (texture) {
texObj = _mesa_lookup_texture(ctx, texture);
}
/* Check dimension-dependent things */
switch (dims) {
case 1:
if (textarget != GL_TEXTURE_1D) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glFramebufferTexture1DEXT(textarget)");
return;
/* The textarget, level, and zoffset parameters are only validated if
* texture is non-zero.
*/
if (texture) {
GLboolean err = GL_TRUE;
texObj = _mesa_lookup_texture(ctx, texture);
if (texObj != NULL) {
err = (texObj->Target == GL_TEXTURE_CUBE_MAP)
? !IS_CUBE_FACE(textarget)
: (texObj->Target != textarget);
}
if (texObj && texObj->Target != GL_TEXTURE_1D) {
if (err) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glFramebufferTexture1DEXT(texture target mismatch)");
"glFramebufferTexture%sEXT(texture target mismatch)",
caller);
return;
}
break;
case 2:
if (textarget != GL_TEXTURE_2D &&
textarget != GL_TEXTURE_RECTANGLE_ARB &&
!IS_CUBE_FACE(textarget)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glFramebufferTexture2DEXT(textarget)");
return;
}
if (texObj) {
if ((texObj->Target == GL_TEXTURE_2D && textarget != GL_TEXTURE_2D) ||
(texObj->Target == GL_TEXTURE_RECTANGLE_ARB
&& textarget != GL_TEXTURE_RECTANGLE_ARB) ||
(texObj->Target == GL_TEXTURE_CUBE_MAP
&& !IS_CUBE_FACE(textarget))) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glFramebufferTexture1DEXT(texture target mismatch)");
return;
}
}
break;
case 3:
if (textarget != GL_TEXTURE_3D) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glFramebufferTexture3DEXT(textarget)");
return;
}
if (texObj && texObj->Target != GL_TEXTURE_3D) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glFramebufferTexture3DEXT(texture target mismatch)");
return;
}
{
if (texObj->Target == GL_TEXTURE_3D) {
const GLint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1);
if (zoffset < 0 || zoffset >= maxSize) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glFramebufferTexture3DEXT(zoffset)");
"glFramebufferTexture%sEXT(zoffset)",
caller);
return;
}
}
break;
default:
_mesa_problem(ctx, "Unexpected dims in error_check_framebuffer_texture");
return;
}
if ((level < 0) || level >= _mesa_max_texture_levels(ctx, textarget)) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glFramebufferTexture%dDEXT(level)", dims);
return;
if ((level < 0) ||
(level >= _mesa_max_texture_levels(ctx, texObj->Target))) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glFramebufferTexture%sEXT(level)", caller);
return;
}
}
att = _mesa_get_attachment(ctx, fb, attachment);
if (att == NULL) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glFramebufferTexture%dDEXT(attachment)", dims);
"glFramebufferTexture%sEXT(attachment)", caller);
return;
}
@@ -1271,9 +1240,16 @@ void GLAPIENTRY
_mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment,
GLenum textarget, GLuint texture, GLint level)
{
const GLint zoffset = 0;
framebuffer_texture(1, target, attachment, textarget, texture,
level, zoffset);
GET_CURRENT_CONTEXT(ctx);
if ((texture != 0) && (textarget != GL_TEXTURE_1D)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glFramebufferTexture1DEXT(textarget)");
return;
}
framebuffer_texture(ctx, "1D", target, attachment, textarget, texture,
level, 0);
}
@@ -1281,9 +1257,19 @@ void GLAPIENTRY
_mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment,
GLenum textarget, GLuint texture, GLint level)
{
const GLint zoffset = 0;
framebuffer_texture(2, target, attachment, textarget, texture,
level, zoffset);
GET_CURRENT_CONTEXT(ctx);
if ((texture != 0) &&
(textarget != GL_TEXTURE_2D) &&
(textarget != GL_TEXTURE_RECTANGLE_ARB) &&
(!IS_CUBE_FACE(textarget))) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glFramebufferTexture2DEXT(textarget)");
return;
}
framebuffer_texture(ctx, "2D", target, attachment, textarget, texture,
level, 0);
}
@@ -1292,12 +1278,19 @@ _mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment,
GLenum textarget, GLuint texture,
GLint level, GLint zoffset)
{
framebuffer_texture(3, target, attachment, textarget, texture,
GET_CURRENT_CONTEXT(ctx);
if ((texture != 0) && (textarget != GL_TEXTURE_3D)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glFramebufferTexture3DEXT(textarget)");
return;
}
framebuffer_texture(ctx, "3D", target, attachment, textarget, texture,
level, zoffset);
}
void GLAPIENTRY
_mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment,
GLenum renderbufferTarget,

View File

@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
* Version: 6.5.3
* Version: 7.0
*
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
@@ -64,27 +64,27 @@
*/
static GLboolean
_mesa_type_is_packed(GLenum type)
{
switch (type) {
case GL_UNSIGNED_BYTE_3_3_2:
case GL_UNSIGNED_BYTE_2_3_3_REV:
case GL_UNSIGNED_SHORT_5_6_5:
case GL_UNSIGNED_SHORT_5_6_5_REV:
case GL_UNSIGNED_SHORT_4_4_4_4:
case GL_UNSIGNED_SHORT_4_4_4_4_REV:
case GL_UNSIGNED_SHORT_5_5_5_1:
case GL_UNSIGNED_SHORT_1_5_5_5_REV:
case GL_UNSIGNED_INT_8_8_8_8:
case GL_UNSIGNED_INT_8_8_8_8_REV:
case GL_UNSIGNED_INT_10_10_10_2:
case GL_UNSIGNED_INT_2_10_10_10_REV:
case GL_UNSIGNED_SHORT_8_8_MESA:
case GL_UNSIGNED_SHORT_8_8_REV_MESA:
case GL_UNSIGNED_INT_24_8_EXT:
return GL_TRUE;
}
{
switch (type) {
case GL_UNSIGNED_BYTE_3_3_2:
case GL_UNSIGNED_BYTE_2_3_3_REV:
case GL_UNSIGNED_SHORT_5_6_5:
case GL_UNSIGNED_SHORT_5_6_5_REV:
case GL_UNSIGNED_SHORT_4_4_4_4:
case GL_UNSIGNED_SHORT_4_4_4_4_REV:
case GL_UNSIGNED_SHORT_5_5_5_1:
case GL_UNSIGNED_SHORT_1_5_5_5_REV:
case GL_UNSIGNED_INT_8_8_8_8:
case GL_UNSIGNED_INT_8_8_8_8_REV:
case GL_UNSIGNED_INT_10_10_10_2:
case GL_UNSIGNED_INT_2_10_10_10_REV:
case GL_UNSIGNED_SHORT_8_8_MESA:
case GL_UNSIGNED_SHORT_8_8_REV_MESA:
case GL_UNSIGNED_INT_24_8_EXT:
return GL_TRUE;
}
return GL_FALSE;
return GL_FALSE;
}
/**
@@ -103,9 +103,8 @@ _mesa_type_is_packed(GLenum type)
static void
flip_bytes( GLubyte *p, GLuint n )
{
register GLuint i, a, b;
for (i=0;i<n;i++) {
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) |
@@ -129,9 +128,8 @@ flip_bytes( GLubyte *p, GLuint n )
void
_mesa_swap2( GLushort *p, GLuint n )
{
register GLuint i;
for (i=0;i<n;i++) {
GLuint i;
for (i = 0; i < n; i++) {
p[i] = (p[i] >> 8) | ((p[i] << 8) & 0xff00);
}
}
@@ -144,9 +142,8 @@ _mesa_swap2( GLushort *p, GLuint n )
void
_mesa_swap4( GLuint *p, GLuint n )
{
register GLuint i, a, b;
for (i=0;i<n;i++) {
GLuint i, a, b;
for (i = 0; i < n; i++) {
b = p[i];
a = (b >> 24)
| ((b >> 8) & 0xff00)
@@ -4263,60 +4260,68 @@ _mesa_unpack_image( GLuint dimensions,
const GLvoid *src = _mesa_image_address(dimensions, unpack, pixels,
width, height, format, type, img, row, 0);
if ((type == GL_BITMAP) && (unpack->SkipPixels & 0x7)) {
GLint i;
flipBytes = GL_FALSE;
if (unpack->LsbFirst) {
GLubyte srcMask = 1 << (unpack->SkipPixels & 0x7);
GLubyte dstMask = 128;
const GLubyte *s = src;
GLubyte *d = dst;
*d = 0;
for (i = 0; i < width; i++) {
if (*s & srcMask) {
*d |= dstMask;
}
if (srcMask == 128) {
srcMask = 1;
s++;
} else {
srcMask = srcMask << 1;
}
if (dstMask == 1) {
dstMask = 128;
d++;
*d = 0;
} else {
dstMask = dstMask >> 1;
}
}
} else {
GLubyte srcMask = 128 >> (unpack->SkipPixels & 0x7);
GLubyte dstMask = 128;
const GLubyte *s = src;
GLubyte *d = dst;
if ((type == GL_BITMAP) && (unpack->SkipPixels & 0x7)) {
GLint i;
flipBytes = GL_FALSE;
if (unpack->LsbFirst) {
GLubyte srcMask = 1 << (unpack->SkipPixels & 0x7);
GLubyte dstMask = 128;
const GLubyte *s = src;
GLubyte *d = dst;
*d = 0;
for (i = 0; i < width; i++) {
if (*s & srcMask) {
*d |= dstMask;
}
if (srcMask == 128) {
srcMask = 1;
s++;
}
else {
srcMask = srcMask << 1;
}
if (dstMask == 1) {
dstMask = 128;
d++;
*d = 0;
for (i = 0; i < width; i++) {
if (*s & srcMask) {
*d |= dstMask;
}
if (srcMask == 1) {
srcMask = 128;
s++;
} else {
srcMask = srcMask >> 1;
}
if (dstMask == 1) {
dstMask = 128;
d++;
*d = 0;
} else {
dstMask = dstMask >> 1;
}
}
}
} else
_mesa_memcpy(dst, src, bytesPerRow);
}
else {
dstMask = dstMask >> 1;
}
}
}
else {
GLubyte srcMask = 128 >> (unpack->SkipPixels & 0x7);
GLubyte dstMask = 128;
const GLubyte *s = src;
GLubyte *d = dst;
*d = 0;
for (i = 0; i < width; i++) {
if (*s & srcMask) {
*d |= dstMask;
}
if (srcMask == 1) {
srcMask = 128;
s++;
}
else {
srcMask = srcMask >> 1;
}
if (dstMask == 1) {
dstMask = 128;
d++;
*d = 0;
}
else {
dstMask = dstMask >> 1;
}
}
}
}
else {
_mesa_memcpy(dst, src, bytesPerRow);
}
/* byte flipping/swapping */
if (flipBytes) {
flip_bytes((GLubyte *) dst, bytesPerRow);

View File

@@ -20,9 +20,9 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Version: 7.0
*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2007 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"),
@@ -921,14 +921,11 @@ _mesa_vsprintf( char *str, const char *fmt, va_list args )
/*@{*/
/**
* Display a warning.
* Report a warning (a recoverable error condition) to stderr if
* either DEBUG is defined or the MESA_DEBUG env var is set.
*
* \param ctx GL context.
* \param fmtString printf() alike format string.
*
* If debugging is enabled (either at compile-time via the DEBUG macro, or
* run-time via the MESA_DEBUG environment variable), prints the warning to
* stderr via fprintf().
*/
void
_mesa_warning( GLcontext *ctx, const char *fmtString, ... )
@@ -951,13 +948,11 @@ _mesa_warning( GLcontext *ctx, const char *fmtString, ... )
}
/**
* This function is called when the Mesa user has stumbled into a code
* path which may not be implemented fully or correctly.
* Report an internla implementation problem.
* Prints the message to stderr via fprintf().
*
* \param ctx GL context.
* \param s problem description string.
*
* Prints the message to stderr via fprintf().
*/
void
_mesa_problem( const GLcontext *ctx, const char *fmtString, ... )
@@ -975,18 +970,16 @@ _mesa_problem( const GLcontext *ctx, const char *fmtString, ... )
}
/**
* Display an error message.
* Record an OpenGL state error. These usually occur when the users
* passes invalid parameters to a GL function.
*
* If in debug mode, print error message.
* Also, record the error code by calling _mesa_record_error().
* If debugging is enabled (either at compile-time via the DEBUG macro, or
* run-time via the MESA_DEBUG environment variable), report the error with
* _mesa_debug().
*
* \param ctx the GL context.
* \param error the error value.
* \param fmtString printf() style format string, followed by optional args
*
* If debugging is enabled (either at compile-time via the DEBUG macro, or
* run-time via the MESA_DEBUG environment variable), interperts the error code and
* prints the error message via _mesa_debug().
*/
void
_mesa_error( GLcontext *ctx, GLenum error, const char *fmtString, ... )
@@ -1056,12 +1049,11 @@ _mesa_error( GLcontext *ctx, GLenum error, const char *fmtString, ... )
}
/**
* Report debug information.
* Report debug information. Print error message to stderr via fprintf().
* No-op if DEBUG mode not enabled.
*
* \param ctx GL context.
* \param fmtString printf() alike format string.
*
* Prints the message to stderr via fprintf().
* \param fmtString printf()-style format string, followed by optional args.
*/
void
_mesa_debug( const GLcontext *ctx, const char *fmtString, ... )

View File

@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
* Version: 6.5.3
* Version: 7.0
*
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2007 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"),
@@ -1117,6 +1117,13 @@ compute_light_positions( GLcontext *ctx )
}
light->_VP_inf_spot_attenuation = 1.0;
}
else {
/* positional light w/ homogeneous coordinate, divide by W */
GLfloat wInv = 1.0 / light->_Position[3];
light->_Position[0] *= wInv;
light->_Position[1] *= wInv;
light->_Position[2] *= wInv;
}
if (light->_Flags & LIGHT_SPOT) {
if (ctx->_NeedEyeCoords) {

View File

@@ -5,9 +5,9 @@
/*
* Mesa 3-D graphics library
* Version: 6.5.1
* Version: 7.0
*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2007 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"),
@@ -61,10 +61,6 @@ _mesa_PointSize( GLfloat size )
ctx->Point.MinSize,
ctx->Point.MaxSize);
ctx->Point._Attenuated = (ctx->Point.Params[0] != 1.0 ||
ctx->Point.Params[1] != 0.0 ||
ctx->Point.Params[2] != 0.0);
if (ctx->Driver.PointSize)
ctx->Driver.PointSize(ctx, size);
}
@@ -122,6 +118,9 @@ _mesa_PointParameterfvEXT( GLenum pname, const GLfloat *params)
return;
FLUSH_VERTICES(ctx, _NEW_POINT);
COPY_3V(ctx->Point.Params, params);
ctx->Point._Attenuated = (ctx->Point.Params[0] != 1.0 ||
ctx->Point.Params[1] != 0.0 ||
ctx->Point.Params[2] != 0.0);
}
else {
_mesa_error(ctx, GL_INVALID_ENUM,

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