Merge branch 'master' of git+ssh://joukj@git.freedesktop.org/git/mesa/mesa

This commit is contained in:
Jouk 2007-06-08 13:38:24 +02:00
commit 55f8b70530
202 changed files with 11510 additions and 9345 deletions

View file

@ -162,10 +162,10 @@ ultrix-gcc:
# Rules for making release tarballs
DIRECTORY = Mesa-7.0pre
LIB_NAME = MesaLib-7.0pre
DEMO_NAME = MesaDemos-7.0pre
GLUT_NAME = MesaGLUT-7.0pre
DIRECTORY = Mesa-7.1pre
LIB_NAME = MesaLib-7.1pre
DEMO_NAME = MesaDemos-7.1pre
GLUT_NAME = MesaGLUT-7.1pre
MAIN_FILES = \
$(DIRECTORY)/Makefile* \

View file

@ -9,7 +9,7 @@ CONFIG_NAME = default
# Version info
MESA_MAJOR=7
MESA_MINOR=0
MESA_MINOR=1
MESA_TINY=0
# external projects. This should be useless now that we use libdrm.

View file

@ -24,7 +24,8 @@ 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
-DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER \
-DHAVE_ALIAS
CFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
$(ASM_FLAGS) -std=c99 -ffast-math

View file

@ -0,0 +1,805 @@
Name
MESA_texture_array
Name Strings
GL_MESA_texture_array
Contact
Ian Romanick, IBM (idr 'at' us.ibm.com)
IP Status
No known IP issues.
Status
Shipping in Mesa 7.1
Version
$Date: 2007/05/16$ $Revision: 0.4$
Number
TBD
Dependencies
OpenGL 1.2 or GL_EXT_texture3D is required.
Support for ARB_fragment_program is assumed, but not required.
Support for ARB_fragment_program_shadow is assumed, but not required.
Support for EXT_framebuffer_object is assumed, but not required.
Written based on the wording of the OpenGL 2.0 specification and
ARB_fragment_program_shadow but not dependent on them.
Overview
There are a number of circumstances where an application may wish to
blend two textures out of a larger set of textures. Moreover, in some
cases the selected textures may vary on a per-fragment basis within
a polygon. Several examples include:
1. High dynamic range textures. The application stores several
different "exposures" of an image as different textures. On a
per-fragment basis, the application selects which exposures are
used.
2. A terrain engine where the altitude of a point determines the
texture applied to it. If the transition is from beach sand to
grass to rocks to snow, the application will store each texture
in a different texture map, and dynamically select which two
textures to blend at run-time.
3. Storing short video clips in textures. Each depth slice is a
single frame of video.
Several solutions to this problem have been proposed, but they either
involve using a separate texture unit for each texture map or using 3D
textures without mipmaps. Both of these options have major drawbacks.
This extension provides a third alternative that eliminates the major
drawbacks of both previous methods. A new texture target,
TEXTURE_2D_ARRAY, is added that functions identically to TEXTURE_3D in
all aspects except the sizes of the non-base level images. In
traditional 3D texturing, the size of the N+1 LOD is half the size
of the N LOD in all three dimensions. For the TEXTURE_2D_ARRAY target,
the height and width of the N+1 LOD is halved, but the depth is the
same for all levels of detail. The texture then becomes an array of
2D textures. The per-fragment texel is selected by the R texture
coordinate.
References:
http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_topic;f=3;t=011557
http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_topic;f=3;t=000516
http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_topic;f=3;t=011903
http://www.delphi3d.net/articles/viewarticle.php?article=terraintex.htm
New Procedures and Functions
All functions come directly from EXT_texture_array.
void FramebufferTextureLayerEXT(enum target, enum attachment,
uint texture, int level, int layer);
New Tokens
All token names and values come directly from EXT_texture_array.
Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, by
the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and
GetDoublev, and by the <target> parameter of TexImage3D, GetTexImage,
GetTexLevelParameteriv, GetTexLevelParameterfv, GetTexParameteriv, and
GetTexParameterfv:
TEXTURE_1D_ARRAY_EXT 0x8C18
TEXTURE_2D_ARRAY_EXT 0x8C1A
Accepted by the <target> parameter of TexImage2D, TexSubImage2D,
CopyTexImage2D, CopyTexSubImage2D, CompressedTexImage2D,
CompressedTexSubImage2D, GetTexLevelParameteriv, and
GetTexLevelParameterfv:
TEXTURE_1D_ARRAY_EXT
PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19
Accepted by the <target> parameter of TexImage3D, TexSubImage3D,
CopyTexSubImage3D, CompressedTexImage3D, CompressedTexSubImage3D,
GetTexLevelParameteriv, and GetTexLevelParameterfv:
TEXTURE_2D_ARRAY_EXT
PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B
Accepted by the <pname> parameter of GetBooleanv, GetIntegerv,
GetFloatv, and GetDoublev
TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C
TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D
MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF
Accepted by the <param> parameter of TexParameterf, TexParameteri,
TexParameterfv, and TexParameteriv when the <pname> parameter is
TEXTURE_COMPARE_MODE_ARB:
COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E
(Note: COMPARE_REF_DEPTH_TO_TEXTURE_EXT is simply an alias for the
existing COMPARE_R_TO_TEXTURE token in OpenGL 2.0; the alternate name
reflects the fact that the R coordinate is not always used.)
Accepted by the <internalformat> parameter of TexImage3D and
CompressedTexImage3D, and by the <format> parameter of
CompressedTexSubImage3D:
COMPRESSED_RGB_S3TC_DXT1_EXT
COMPRESSED_RGBA_S3TC_DXT1_EXT
COMPRESSED_RGBA_S3TC_DXT3_EXT
COMPRESSED_RGBA_S3TC_DXT5_EXT
Accepted by the <pname> parameter of
GetFramebufferAttachmentParameterivEXT:
FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4
(Note: FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER is simply an alias for the
FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT token provided in
EXT_framebuffer_object. This extension generalizes the notion of
"<zoffset>" to include layers of an array texture.)
Additions to Chapter 2 of the OpenGL 2.0 Specification (OpenGL Operation)
None
Additions to Chapter 3 of the OpenGL 2.0 Specification (Rasterization)
-- Section 3.8.1 "Texture Image Specification"
Change the first paragraph (page 150) to say (spec changes identical to
EXT_texture_array):
"The command
void TexImage3D(enum target, int level, int internalformat,
sizei width, sizei height, sizei depth, int border,
enum format, enum type, void *data);
is used to specify a three-dimensional texture image. target must be one
one of TEXTURE_3D for a three-dimensional texture or
TEXTURE_2D_ARRAY_EXT for an two-dimensional array texture.
Additionally, target may be either PROXY_TEXTURE_3D for a
three-dimensional proxy texture, or PROXY_TEXTURE_2D_ARRAY_EXT for a
two-dimensional proxy array texture."
Change the fourth paragraph on page 151 to say (spec changes identical
to EXT_texture_array):
"Textures with a base internal format of DEPTH_COMPONENT are supported
by texture image specification commands only if target is TEXTURE_1D,
TEXTURE_2D, TEXTURE_1D_ARRAY_EXT, TEXTURE_2D_ARRAY_EXT,
PROXY_TEXTURE_1D, PROXY_TEXTURE_2D, PROXY_TEXTURE_1D_ARRAY_EXT, or
PROXY_TEXTURE_2D_ARRAY_EXT. Using this format in conjunction with any
other target will result in an INVALID_OPERATION error."
Change the fourth paragraph on page 156 to say (spec changes identical
to EXT_texture_array):
"The command
void TexImage2D(enum target, int level,
int internalformat, sizei width, sizei height,
int border, enum format, enum type, void *data);
is used to specify a two-dimensional texture image. target must be one
of TEXTURE_2D for a two-dimensional texture, TEXTURE_1D_ARRAY_EXT for a
one-dimensional array texture, or one of TEXTURE_CUBE_MAP_POSITIVE_X,
TEXTURE_CUBE_MAP_NEGATIVE_X, TEXTURE_CUBE_MAP_POSITIVE_Y,
TEXTURE_CUBE_MAP_NEGATIVE_Y, TEXTURE_CUBE_MAP_POSITIVE_Z, or
TEXTURE_CUBE_MAP_NEGATIVE_Z for a cube map texture. Additionally,
target may be either PROXY_TEXTURE_2D for a two-dimensional proxy
texture, PROXY_TEXTURE_1D_ARRAY_EXT for a one-dimensional proxy array
texture, or PROXY TEXTURE_CUBE_MAP for a cube map proxy texture in the
special case discussed in section 3.8.11. The other parameters match
the corresponding parameters of TexImage3D.
For the purposes of decoding the texture image, TexImage2D is
equivalent to calling TexImage3D with corresponding arguments and depth
of 1, except that
* The border depth, d_b, is zero, and the depth of the image is
always 1 regardless of the value of border.
* The border height, h_b, is zero if <target> is
TEXTURE_1D_ARRAY_EXT, and <border> otherwise.
* Convolution will be performed on the image (possibly changing its
width and height) if SEPARABLE 2D or CONVOLUTION 2D is enabled.
* UNPACK SKIP IMAGES is ignored."
-- Section 3.8.2 "Alternate Texture Image Specification Commands"
Change the second paragraph (page 159) (spec changes identical
to EXT_texture_array):
"The command
void CopyTexImage2D(enum target, int level,
enum internalformat, int x, int y, sizei width,
sizei height, int border);
defines a two-dimensional texture image in exactly the manner of
TexImage2D, except that the image data are taken from the framebuffer
rather than from client memory. Currently, target must be one of
TEXTURE_2D, TEXTURE_1D_ARRAY_EXT, TEXTURE_CUBE_MAP_POSITIVE_X,
TEXTURE_CUBE_MAP_NEGATIVE_X, TEXTURE_CUBE MAP_POSITIVE_Y,
TEXTURE_CUBE_MAP_NEGATIVE_Y, TEXTURE_CUBE_MAP_POSITIVE_Z, or
TEXTURE_CUBE_MAP_NEGATIVE_Z.
Change the last paragraph on page 160 to say (spec changes identical
to EXT_texture_array):
"Currently the target arguments of TexSubImage1D and CopyTexSubImage1D
must be TEXTURE_1D, the target arguments of TexSubImage2D and
CopyTexSubImage2D must be one of TEXTURE_2D, TEXTURE_1D_ARRAY_EXT,
TEXTURE_CUBE_MAP_POSITIVE_X, TEXTURE_CUBE_MAP_NEGATIVE_X,
TEXTURE_CUBE_MAP_POSITIVE_Y, TEXTURE_CUBE_MAP_NEGATIVE_Y,
TEXTURE_CUBE_MAP_POSITIVE_Z, or TEXTURE_CUBE_MAP_NEGATIVE_Z, and the
target arguments of TexSubImage3D and CopyTexSubImage3D must be
TEXTURE_3D or TEXTURE_2D_ARRAY_EXT. ..."
-- Section 3.8.4 "Texture Parameters"
Change the first paragraph (page 166) to say:
"Various parameters control how the texel array is treated when
specified or changed, and when applied to a fragment. Each parameter is
set by calling
void TexParameter{if}(enum target, enum pname, T param);
void TexParameter{if}v(enum target, enum pname, T params);
target is the target, either TEXTURE_1D, TEXTURE_2D, TEXTURE_3D,
TEXTURE_CUBE_MAP, TEXTURE_1D_ARRAY_EXT, or TEXTURE_2D_ARRAY_EXT."
-- Section 3.8.8 "Texture Minification" in the section "Scale Factor and Level of Detail"
Change the first paragraph (page 172) to say:
"Let s(x,y) be the function that associates an s texture coordinate
with each set of window coordinates (x,y) that lie within a primitive;
define t(x,y) and r(x,y) analogously. Let u(x,y) = w_t * s(x,y),
v(x,y) = h_t * t(x,y), and w(x,y) = d_t * r(x,y), where w_t, h_t,
and d_t are as defined by equations 3.15, 3.16, and 3.17 with
w_s, h_s, and d_s equal to the width, height, and depth of the
image array whose level is level_base. For a one-dimensional
texture or a one-dimensional array texture, define v(x,y) = 0 and
w(x,y) = 0; for a two-dimensional texture or a two-dimensional array
texture, define w(x,y) = 0..."
-- Section 3.8.8 "Texture Minification" in the section "Mipmapping"
Change the third paragraph (page 174) to say:
"For a two-dimensional texture, two-dimensional array texture, or
cube map texture,"
Change the fourth paragraph (page 174) to say:
"And for a one-dimensional texture or a one-dimensional array texture,"
After the first paragraph (page 175) add:
"For one-dimensional array textures, h_b and d_b are treated as 1,
regardless of the actual values, when performing mipmap calculations.
For two-dimensional array textures, d_b is always treated as one,
regardless of the actual value, when performing mipmap calculations."
-- Section 3.8.8 "Automatic Mipmap Generation" in the section "Mipmapping"
Change the third paragraph (page 176) to say (spec changes identical
to EXT_texture_array):
"The contents of the derived arrays are computed by repeated, filtered
reduction of the level_base array. For one- and two-dimensional array
textures, each layer is filtered independently. ..."
-- Section 3.8.8 "Manual Mipmap Generation" in the section "Mipmapping"
Change first paragraph to say (spec changes identical to
EXT_texture_array):
"Mipmaps can be generated manually with the command
void GenerateMipmapEXT(enum target);
where <target> is one of TEXTURE_1D, TEXTURE_2D, TEXTURE_CUBE_MAP,
TEXTURE_3D, TEXTURE_1D_ARRAY, or TEXTURE_2D_ARRAY. Mipmap generation
affects the texture image attached to <target>. ..."
-- Section 3.8.10 "Texture Completeness"
Change the second paragaph (page 177) to say (spec changes identical
to EXT_texture_array):
"For one-, two-, or three-dimensional textures and one- or
two-dimensional array textures, a texture is complete if the following
conditions all hold true:"
-- Section 3.8.11 "Texture State and Proxy State"
Change the second and third paragraphs (page 179) to say (spec changes
identical to EXT_texture_array):
"In addition to image arrays for one-, two-, and three-dimensional
textures, one- and two-dimensional array textures, and the six image
arrays for the cube map texture, partially instantiated image arrays
are maintained for one-, two-, and three-dimensional textures and one-
and two-dimensional array textures. Additionally, a single proxy image
array is maintained for the cube map texture. Each proxy image array
includes width, height, depth, border width, and internal format state
values, as well as state for the red, green, blue, alpha, luminance,
and intensity component resolutions. Proxy image arrays do not include
image data, nor do they include texture properties. When TexImage3D is
executed with target specified as PROXY_TEXTURE_3D, the
three-dimensional proxy state values of the specified level-of-detail
are recomputed and updated. If the image array would not be supported
by TexImage3D called with target set to TEXTURE 3D, no error is
generated, but the proxy width, height, depth, border width, and
component resolutions are set to zero. If the image array would be
supported by such a call to TexImage3D, the proxy state values are set
exactly as though the actual image array were being specified. No pixel
data are transferred or processed in either case.
Proxy arrays for one- and two-dimensional textures and one- and
two-dimensional array textures are operated on in the same way when
TexImage1D is executed with target specified as PROXY_TEXTURE_1D,
TexImage2D is executed with target specified as PROXY_TEXTURE_2D or
PROXY_TEXTURE_1D_ARRAY_EXT, or TexImage3D is executed with target
specified as PROXY_TETXURE_2D_ARRAY_EXT."
-- Section 3.8.12 "Texture Objects"
Change section (page 180) to say (spec changes identical to
EXT_texture_array):
"In addition to the default textures TEXTURE_1D, TEXTURE_2D,
TEXTURE_3D, TEXTURE_CUBE_MAP, TEXTURE_1D_ARRAY_EXT, and TEXTURE_2D_EXT,
named one-, two-, and three-dimensional, cube map, and one- and
two-dimensional array texture objects can be created and operated upon.
The name space for texture objects is the unsigned integers, with zero
reserved by the GL.
A texture object is created by binding an unused name to TEXTURE_1D,
TEXTURE_2D, TEXTURE_3D, TEXTURE_CUBE_MAP, TEXTURE_1D_ARRAY_EXT, or
TEXTURE_2D_ARRAY_EXT. The binding is effected by calling
void BindTexture(enum target, uint texture);
with <target> set to the desired texture target and <texture> set to
the unused name. The resulting texture object is a new state vector,
comprising all the state values listed in section 3.8.11, set to the
same initial values. If the new texture object is bound to TEXTURE_1D,
TEXTURE_2D, TEXTURE_3D, TEXTURE_CUBE_MAP, TEXTURE_1D_ARRAY_EXT, or
TEXTURE_2D_ARRAY_EXT, it is and remains a one-, two-,
three-dimensional, cube map, one- or two-dimensional array texture
respectively until it is deleted.
BindTexture may also be used to bind an existing texture object to
either TEXTURE_1D, TEXTURE_2D, TEXTURE_3D, TEXTURE_CUBE_MAP,
TEXTURE_1D_ARRAY_EXT, or TEXTURE_2D_ARRAY_EXT. The error
INVALID_OPERATION is generated if an attempt is made to bind a texture
object of different dimensionality than the specified target. If the
bind is successful no change is made to the state of the bound texture
object, and any previous binding to target is broken.
While a texture object is bound, GL operations on the target to which
it is bound affect the bound object, and queries of the target to which
it is bound return state from the bound object. If texture mapping of
the dimensionality of the target to which a texture object is bound is
enabled, the state of the bound texture object directs the texturing
operation.
In the initial state, TEXTURE_1D, TEXTURE_2D, TEXTURE_3D,
TEXTURE_CUBE_MAP, TEXTURE_1D_ARRAY_EXT, and TEXTURE_2D_ARRAY_EXT have
one-, two-, three-dimensional, cube map, and one- and two-dimensional
array texture state vectors respectively associated with them. In order
that access to these initial textures not be lost, they are treated as
texture objects all of whose names are 0. The initial one-, two-,
three-dimensional, cube map, one- and two-dimensional array textures
are therefore operated upon, queried, and applied as TEXTURE_1D,
TEXTURE_2D, TEXTURE_3D, TEXTURE_CUBE_MAP, TEXTURE_1D_ARRAY_EXT, and
TEXTURE_2D_ARRAY_EXT respectively while 0 is bound to the corresponding
targets.
Change second paragraph on page 181 to say (spec changes identical to
EXT_texture_array):
"... If a texture that is currently bound to one of the targets
TEXTURE_1D, TEXTURE_2D, TEXTURE_3D, TEXTURE_CUBE_MAP,
TEXTURE_1D_ARRAY_EXT, or TEXTURE_2D_ARRAY_EXT is deleted, it is as
though BindTexture had been executed with the same target and texture
zero. ..."
Change second paragraph on page 182 to say (spec changes identical to
EXT_texture_array):
"The texture object name space, including the initial one-, two-, and
three dimensional, cube map, and one- and two-dimensional array texture
objects, is shared among all texture units. ..."
-- Section 3.8.14 "Depth Texture Comparison Modes" in "Texture Comparison Modes"
Change second through fourth paragraphs (page 188) to say:
"Let D_t be the depth texture value, in the range [0, 1]. For
texture lookups from one- and two-dimesional, rectangle, and
one-dimensional array targets, let R be the interpolated <r>
texture coordinate, clamped to the range [0, 1]. For texture lookups
from two-dimesional array texture targets, let R be the interpolated
<q> texture coordinate, clamped to the range [0, 1]. Then the
effective texture value L_t, I_t, or A_t is computed as follows:
If the value of TEXTURE_COMPARE_MODE is NONE, then
r = Dt
If the value of TEXTURE_COMPARE_MODE is
COMPARE_REF_DEPTH_TO_TEXTURE_EXT), then r depends on the texture
comparison function as shown in table 3.27."
-- Section 3.8.15 "Texture Application"
Change the first paragraph (page 189) to say:
"Texturing is enabled or disabled using the generic Enable and Disable
commands, respectively, with the symbolic constants TEXTURE_1D,
TEXTURE_2D, TEXTURE_3D, TEXTURE_CUBE_MAP, TEXTURE_1D_ARRAY_EXT, or
TEXTURE_2D_ARRAY_EXT to enable one-, two-, three-dimensional, cube
map, one-dimensional array, or two-dimensional array texture,
respectively. If both two- and one-dimensional textures are enabled,
the two-dimensional texture is used. If the three-dimensional and
either of the two- or one-dimensional textures is enabled, the
three-dimensional texture is used. If the cube map texture and any of
the three-, two-, or one-dimensional textures is enabled, then cube map
texturing is used. If one-dimensional array texture is enabled and any
of cube map, three-, two-, or one-dimensional textures is enabled,
one-dimensional array texturing is used. If two-dimensional array
texture is enabled and any of cube map, three-, two-, one-dimensional
textures or one-dimensional array texture is enabled, two-dimensional
array texturing is used..."
-- Section 3.11.2 of ARB_fragment_program (Fragment Program Grammar and Restrictions):
(mostly add to existing grammar rules)
<optionName> ::= "MESA_texture_array"
<texTarget> ::= "1D"
| "2D"
| "3D"
| "CUBE"
| "RECT"
| <arrayTarget> (if program option is present)
| <shadowTarget> (if program option is present)
<arrayTarget> ::= "ARRAY1D"
| "ARRAY2D"
<shadowTarget> ::= "SHADOW1D"
| "SHADOW2D"
| "SHADOWRECT"
| <shadowArrayTarget> (if program option is present)
<shadowArrayTarget> ::= "SHADOWARRAY1D"
| "SHADOWARRAY2D"
-- Add Section 3.11.4.5.4 "Texture Stack Option"
"If a fragment program specifies the "MESA_texture_array" program
option, the <texTarget> rule is modified to add the texture targets
ARRAY1D and ARRAY2D (See Section 3.11.2)."
-- Section 3.11.6 "Fragment Program Texture Instruction Set"
(replace 1st and 2nd paragraphs with the following paragraphs)
"The first three texture instructions described below specify the
mapping of 4-tuple input vectors to 4-tuple output vectors.
The sampling of the texture works as described in section 3.8,
except that texture environments and texture functions are not
applicable, and the texture enables hierarchy is replaced by explicit
references to the desired texture target (i.e., 1D, 2D, 3D, cube map,
rectangle, ARRAY1D, ARRAY2D). These texture instructions specify
how the 4-tuple is mapped into the coordinates used for sampling. The
following function is used to describe the texture sampling in the
descriptions below:
vec4 TextureSample(vec4 coord, float lodBias, int texImageUnit,
enum texTarget);
Note that not all four components of the texture coordinates <coord>
are used by all texture targets. Component usage for each <texTarget>
is defined in table X.
coordinates used
texTarget Texture Type s t r layer shadow
---------------- --------------------- ----- ----- ------
1D TEXTURE_1D x - - - -
2D TEXTURE_2D x y - - -
3D TEXTURE_3D x y z - -
CUBE TEXTURE_CUBE_MAP x y z - -
RECT TEXTURE_RECTANGLE_ARB x y - - -
ARRAY1D TEXTURE_1D_ARRAY_EXT x - - y -
ARRAY2D TEXTURE_2D_ARRAY_EXT x y - z -
SHADOW1D TEXTURE_1D x - - - z
SHADOW2D TEXTURE_2D x y - - z
SHADOWRECT TEXTURE_RECTANGLE_ARB x y - - z
SHADOWARRAY1D TEXTURE_1D_ARRAY_EXT x - - y z
SHADOWARRAY2D TEXTURE_2D_ARRAY_EXT x y - z w
Table X: Texture types accessed for each of the <texTarget>, and
coordinate mappings. The "coordinates used" column indicate the
input values used for each coordinate of the texture lookup, the
layer selector for array textures, and the reference value for
texture comparisons."
-- Section 3.11.6.2 "TXP: Project coordinate and map to color"
Add to the end of the section:
"A program will fail to load if the TXP instruction is used in
conjunction with the SHADOWARRAY2D target."
Additions to Chapter 4 of the OpenGL 2.0 Specification (Per-Fragment Operations)
-- Section 4.4.2.3 "Attaching Texture Images to a Framebuffer"
Add to the end of the section (spec changes identical to
EXT_texture_array):
"The command
void FramebufferTextureLayerEXT(enum target, enum attachment,
uint texture, int level, int layer);
operates identically to FramebufferTexture3DEXT, except that it
attaches a single layer of a three-dimensional texture or a one- or
two-dimensional array texture. <layer> is an integer indicating the
layer number, and is treated identically to the <zoffset> parameter in
FramebufferTexture3DEXT. The error INVALID_VALUE is generated if
<layer> is negative. The error INVALID_OPERATION is generated if
<texture> is non-zero and is not the name of a three dimensional
texture or one- or two-dimensional array texture. Unlike
FramebufferTexture3D, no <textarget> parameter is accepted.
If <texture> is non-zero and the command does not result in an error,
the framebuffer attachment state corresponding to <attachment> is
updated as in the other FramebufferTexture commands, except that
FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT is set to <layer>."
-- Section 4.4.4.1 "Framebuffer Attachment Completeness"
Add to the end of the list of completeness rules (spec changes
identical to EXT_texture_array):
"* If FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT is TEXTURE and
FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT names a one- or
two-dimensional array texture, then
FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT must be smaller than the
number of layers in the texture."
Additions to Chapter 5 of the OpenGL 2.0 Specification (Special Functions)
-- Section 5.4 "Display Lists"
Change the first paragraphi on page 242 to say (spec changes
identical to EXT_texture_array):
"TexImage3D, TexImage2D, TexImage1D, Histogram, and ColorTable are
executed immediately when called with the corresponding proxy arguments
PROXY_TEXTURE_3D or PROXY_TEXTURE_2D_ARRAY_EXT; PROXY_TEXTURE_2D,
PROXY_TEXTURE_CUBE_MAP, or PROXY_TEXTURE_1D_ARRAY_EXT;
PROXY_TEXTURE_1D; PROXY_HISTOGRAM; and PROXY_COLOR_TABLE,
PROXY_POST_CONVOLUTION_COLOR_TABLE, or
PROXY_POST_COLOR_MATRIX_COLOR_TABLE."
Additions to Chapter 6 of the OpenGL 2.0 Specification (State and State Requests)
-- Section 6.1.3 "Enumerated Queries"
Add after the line beginning "If the value of
FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT is TEXTURE" (spec changes
identical to EXT_texture_array):
"If <pname> is FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT and the
texture object named FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT is a
three-dimensional texture or a one- or two-dimensional array texture,
then <params> will contain the number of texture layer attached to the
attachment point. Otherwise, <params> will contain the value zero."
-- Section 6.1.4 "Texture Queries"
Change the first three paragraphs (page 248) to say (spec changes
identical to EXT_texture_array):
"The command
void GetTexImage(enum tex, int lod, enum format,
enum type, void *img);
is used to obtain texture images. It is somewhat different from the
other get commands; tex is a symbolic value indicating which texture
(or texture face in the case of a cube map texture target name) is to
be obtained. TEXTURE_1D, TEXTURE_2D, TEXTURE_3D, TEXTURE_1D_ARRAY_EXT,
and TEXTURE_2D_ARRAY_EXT indicate a one-, two-, or three-dimensional
texture, or one- or two-dimensional array texture, respectively.
TEXTURE_CUBE_MAP_POSITIVE_X, ...
GetTexImage obtains... from the first image to the last for
three-dimensional textures. One- and two-dimensional array textures
are treated as two- and three-dimensional images, respectively, where
the layers are treated as rows or images. These groups are then...
For three-dimensional and two-dimensional array textures, pixel storage
operations are applied as if the image were two-dimensional, except
that the additional pixel storage state values PACK_IMAGE_HEIGHT and
PACK_SKIP_IMAGES are applied. ..."
Additions to Appendix A of the OpenGL 2.0 Specification (Invariance)
None
Additions to the AGL/GLX/WGL Specifications
None
GLX Protocol
None
Dependencies on ARB_fragment_program
If ARB_fragment_program is not supported, the changes to section 3.11
should be ignored.
Dependencies on EXT_framebuffer_object
If EXT_framebuffer_object is not supported, the changes to section
3.8.8 ("Manual Mipmap Generation"), 4.4.2.3, and 6.1.3 should be ignored.
Dependencies on EXT_texture_compression_s3tc and NV_texture_compression_vtc
(Identical dependency as EXT_texture_array.)
S3TC texture compression is supported for two-dimensional array textures.
When <target> is TEXTURE_2D_ARRAY_EXT, each layer is stored independently
as a compressed two-dimensional textures. When specifying or querying
compressed images using one of the S3TC formats, the images are provided
and/or returned as a series of two-dimensional textures stored
consecutively in memory, with the layer closest to zero specified first.
For array textures, images are not arranged in 4x4x4 or 4x4x2 blocks as in
the three-dimensional compression format provided in the
EXT_texture_compression_vtc extension. Pixel store parameters, including
those specific to three-dimensional images, are ignored when compressed
image data are provided or returned, as in the
EXT_texture_compression_s3tc extension.
S3TC compression is not supported for one-dimensional texture targets in
EXT_texture_compression_s3tc, and is not supported for one-dimensional
array textures in this extension. If compressed one-dimensional arrays
are needed, use a two-dimensional texture with a height of one.
This extension allows the use of the four S3TC internal format types in
TexImage3D, CompressedTexImage3D, and CompressedTexSubImage3D calls.
Errors
None
New State
(add to table 6.15, p. 276)
Initial
Get Value Type Get Command Value Description Sec. Attribute
---------------------------- ----- ----------- ----- -------------------- ------ ---------
TEXTURE_BINDING_1D_ARRAY_EXT 2*xZ+ GetIntegerv 0 texture object bound 3.8.12 texture
to TEXTURE_1D_ARRAY
TEXTURE_BINDING_2D_ARRAY_EXT 2*xZ+ GetIntegerv 0 texture object bound 3.8.12 texture
to TEXTURE_2D_ARRAY
New Implementation Dependent State
(add to Table 6.32, p. 293)
Minimum
Get Value Type Get Command Value Description Sec. Attribute
---------------------------- ---- ----------- ------- ------------------ ----- ---------
MAX_TEXTURE_ARRAY_LAYERS_EXT Z+ GetIntegerv 64 maximum number of 3.8.1 -
layers for texture
arrays
Issues
(1) Is "texture stack" a good name for this functionality?
NO. The name is changed to "array texture" to match the
nomenclature used by GL_EXT_texture_array.
(2) Should the R texture coordinate be treated as normalized or
un-normalized? If it were un-normalized, floor(R) could be thought
of as a direct index into the array texture. This may be more
convenient for applications.
RESOLVED. All texture coordinates are normalized. The issue of
un-normalized texture coordinates has been discussed in the ARB
before and should be left for a layered extension.
RE-RESOLVED. The R coordinate is un-normalized. Accessing an array
using [0, layers-1] coordinates is much more natural.
(3) How does LOD selection work for stacked textures?
RESOLVED. For 2D array textures the R coordinate is ignored, and
the LOD selection equations for 2D textures are used. For 1D
array textures the T coordinate is ignored, and the LOD selection
equations for 1D textures are used. The expected usage is in a
fragment program with an explicit LOD selection.
(4) What is the maximum size of a 2D array texture? Is it the same
as for a 3D texture, or should a new query be added? How about for 1D
array textures?
RESOLVED. A new query is added.
(5) How are array textures exposed in GLSL?
RESOLVED. Use GL_EXT_texture_array.
(6) Should a 1D array texture also be exposed?
RESOLVED. For orthogonality, yes.
(7) How are stacked textures attached to framebuffer objects?
RESOLVED. Layers of both one- and two-dimensional array textures
are attached using FreambufferTextureLayerEXT. Once attached, the
array texture layer behaves exactly as either a one- or
two-dimensional texture.
(8) How is this extension related to GL_EXT_texture_array?
This extension adapats GL_MESAX_texture_stack to the notation,
indexing, and FBO access of GL_EXT_texture_array. This extension
replaces the GLSL support of GL_EXT_texture_array with
GL_ARB_fragment_program support.
Assembly program support is also provided by GL_NV_gpu_program4.
GL_NV_gpu_program4 also adds support for other features that are
specific to Nvidia hardware, while this extension adds only support
for array textures.
Much of text of this extension that has changed since
GL_MESAX_texture_stack comes directly from either
GL_EXT_texture_array or GL_NV_gpu_program4.
Revision History
||2005/11/15||0.1||idr||Initial draft MESAX version.||
||2005/12/07||0.2||idr||Added framebuffer object interactions.||
||2005/12/12||0.3||idr||Updated fragment program interactions.||
||2007/05/16||0.4||idr||Converted to MESA_texture_array. Brought in line with EXT_texture_array and NV_gpu_program4.||

View file

@ -30,15 +30,20 @@ TBD
<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
</ul>
<h2>Internal code changes</h2>
<ul>
<li>Some texture code consolidation and simplifiction (Ian Romanick)
<li>R300 driver clean-ups.
</ul>

68
docs/relnotes-7.1.html Normal file
View file

@ -0,0 +1,68 @@
<HTML>
<TITLE>Mesa Release Notes</TITLE>
<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
<BODY>
<body bgcolor="#eeeeee">
<H1>Mesa 7.1 Release Notes / (<em>in progress</em>)</H1>
<p>
Mesa 7.1 is a new development release.
</p>
<h2>MD5 checksums</h2>
<pre>
TBD
</pre>
<h2>New features</h2>
<ul>
<li>GL_EXT_texture_from_pixmap extension for Xlib driver
</ul>
<h2>Bug fixes</h2>
<ul>
</ul>
<h2>Internal code changes</h2>
<ul>
</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.1.html">7.1 release notes</A>
<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>

View file

@ -2209,6 +2209,39 @@ GLAPI void GLAPIENTRY glGetProgramRegisterfvMESA(GLenum target, GLsizei len, con
#endif /* GL_MESA_program_debug */
#ifndef GL_MESA_texture_array
#define GL_MESA_texture_array 1
/* GL_MESA_texture_array uses the same enum values as GL_EXT_texture_array.
*/
#ifndef GL_EXT_texture_array
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glFramebufferTextureLayerEXT(GLenum target,
GLenum attachment, GLuint texture, GLint level, GLint layer);
#endif /* GL_GLEXT_PROTOTYPES */
#if 0
/* (temporarily) disabled because of collision with typedef in glext.h
* that happens if apps include both gl.h and glext.h
*/
typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target,
GLenum attachment, GLuint texture, GLint level, GLint layer);
#endif
#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18
#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19
#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A
#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B
#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C
#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D
#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4
#endif
#endif
#ifndef GL_ATI_blend_equation_separate
#define GL_ATI_blend_equation_separate 1

View file

@ -361,6 +361,18 @@ struct __DRIscreenRec {
void * (*createNewContext)(__DRInativeDisplay *dpy, const __GLcontextModes *modes,
int render_type,
void *sharedPrivate, __DRIcontext *pctx);
/**
* Method to override base texture image with a driver specific 'offset'.
* The depth passed in allows e.g. to ignore the alpha channel of texture
* images where the non-alpha components don't occupy a whole texel.
*
* For GLX_EXT_texture_from_pixmap with AIGLX.
*
* \since Internal API version 20070121.
*/
void (*setTexOffset)(__DRIcontext *pDRICtx, GLint texname,
unsigned long long offset, GLint depth, GLuint pitch);
};
/**

View file

@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
* Version: 4.1
* Version: 7.1
*
* Copyright (C) 1999-2002 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"),
@ -397,6 +397,25 @@ extern XMesaBuffer XMesaCreatePBuffer(XMesaVisual v, XMesaColormap cmap,
/*
* Texture from Pixmap
* New in Mesa 7.1
*/
extern void
XMesaBindTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer,
const int *attrib_list);
extern void
XMesaReleaseTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer);
extern XMesaBuffer
XMesaCreatePixmapTextureBuffer(XMesaVisual v, XMesaPixmap p,
XMesaColormap cmap,
int format, int target, int mipmap);
#ifdef __cplusplus
}
#endif

View file

@ -66,6 +66,7 @@ typedef XColor XMesaColor;
#define XMesaDrawPoints XDrawPoints
#define XMesaDrawLine XDrawLine
#define XMesaFillRectangle XFillRectangle
#define XMesaGetImage XGetImage
#define XMesaPutImage XPutImage
#define XMesaCopyArea XCopyArea

View file

@ -39,11 +39,19 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef _XMESA_XF86_H_
#define _XMESA_XF86_H_
#include "GL/glxtokens.h"
#include "scrnintstr.h"
#include "pixmapstr.h"
#include "gcstruct.h"
#include "servermd.h"
typedef struct _XMesaImageRec XMesaImage;
typedef struct _XMesaImageRec {
int width, height;
char *data;
int bytes_per_line; /* Padded to 32 bits */
int bits_per_pixel;
} XMesaImage;
typedef ScreenRec XMesaDisplay;
typedef PixmapPtr XMesaPixmap;
@ -120,6 +128,26 @@ do { \
(*__gc->ops->PolyFillRect)((DrawablePtr)__b, __gc, 1, __r); \
} while (0)
static _X_INLINE XMesaImage *XMesaGetImage(XMesaDisplay *dpy, PixmapPtr p, int x,
int y, unsigned int width,
unsigned int height,
unsigned long plane_mask, int format)
{
XMesaImage *img = Xcalloc(sizeof(*img));
img->width = p->drawable.width;
img->height = p->drawable.height;
img->bits_per_pixel = p->drawable.bitsPerPixel;
img->bytes_per_line = PixmapBytePad(width, p->drawable.depth);
img->data = malloc(height * img->bytes_per_line);
/* Assumes: Images are always in ZPixmap format */
(*p->drawable.pScreen->GetImage)(&p->drawable, x, y, width, height,
plane_mask, ZPixmap, img->data);
return img;
}
#define XMesaPutImage(__d,__b,__gc,__i,__sx,__sy,__x,__y,__w,__h) \
do { \
/* Assumes: Images are always in ZPixmap format */ \

View file

@ -9,6 +9,7 @@
* Added GL_EXT_packed_depth_stencil support on 15 March 2006.
* Added GL_EXT_framebuffer_object support on 27 March 2006.
* Removed old SGIX extension support on 5 April 2006.
* Added vertex / fragment program support on 7 June 2007 (Ian Romanick).
*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
@ -34,6 +35,7 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <GL/glut.h>
#include "showbuffer.h"
@ -67,8 +69,27 @@ static GLboolean NeedNewShadowMap = GL_FALSE;
static GLuint ShadowTexture, GrayTexture;
static GLuint ShadowFBO;
static GLfloat lightModelview[16];
static GLfloat lightProjection[16];
static GLuint vert_prog;
static GLuint frag_progs[3];
static GLuint curr_frag = 0;
static GLuint max_frag = 1;
#define NUM_FRAG_MODES 3
static const char *FragProgNames[] = {
"fixed-function",
"program without \"OPTION ARB_fragment_program_shadow\"",
"program with \"OPTION ARB_fragment_program_shadow\"",
};
static GLboolean HaveFBO = GL_FALSE;
static GLboolean UseFBO = GL_FALSE;
static GLboolean HaveVP = GL_FALSE;
static GLboolean HaveFP = GL_FALSE;
static GLboolean HaveFP_Shadow = GL_FALSE;
static GLboolean UseVP = GL_FALSE;
static GLboolean HavePackedDepthStencil = GL_FALSE;
static GLboolean UsePackedDepthStencil = GL_FALSE;
static GLboolean HaveEXTshadowFuncs = GL_FALSE;
@ -91,6 +112,103 @@ static GLuint DisplayMode;
#define MAT4_MUL(dest_vec, src_mat, src_vec) \
"DP4 " dest_vec ".x, " src_mat "[0], " src_vec ";\n" \
"DP4 " dest_vec ".y, " src_mat "[1], " src_vec ";\n" \
"DP4 " dest_vec ".z, " src_mat "[2], " src_vec ";\n" \
"DP4 " dest_vec ".w, " src_mat "[3], " src_vec ";\n"
#define MAT3_MUL(dest_vec, src_mat, src_vec) \
"DP3 " dest_vec ".x, " src_mat "[0], " src_vec ";\n" \
"DP3 " dest_vec ".y, " src_mat "[1], " src_vec ";\n" \
"DP3 " dest_vec ".z, " src_mat "[2], " src_vec ";\n"
#define NORMALIZE(dest, src) \
"DP3 " dest ".w, " src ", " src ";\n" \
"RSQ " dest ".w, " dest ".w;\n" \
"MUL " dest ", " src ", " dest ".w;\n"
/**
* Vertex program for shadow mapping.
*/
static const char vert_code[] =
"!!ARBvp1.0\n"
"ATTRIB iPos = vertex.position;\n"
"ATTRIB iNorm = vertex.normal;\n"
"PARAM mvinv[4] = { state.matrix.modelview.invtrans };\n"
"PARAM mvp[4] = { state.matrix.mvp };\n"
"PARAM mv[4] = { state.matrix.modelview };\n"
"PARAM texmat[4] = { state.matrix.texture[0] };\n"
"PARAM lightPos = state.light[0].position;\n"
"PARAM ambientCol = state.lightprod[0].ambient;\n"
"PARAM diffuseCol = state.lightprod[0].diffuse;\n"
"TEMP n, lightVec;\n"
"ALIAS V = lightVec;\n"
"ALIAS NdotL = n;\n"
"OUTPUT oPos = result.position;\n"
"OUTPUT oColor = result.color;\n"
"OUTPUT oTex = result.texcoord[0];\n"
/* Transform the vertex to clip coordinates. */
MAT4_MUL("oPos", "mvp", "iPos")
/* Transform the vertex to eye coordinates. */
MAT4_MUL("V", "mv", "iPos")
/* Transform the vertex to projected light coordinates. */
MAT4_MUL("oTex", "texmat", "iPos")
/* Transform the normal to eye coordinates. */
MAT3_MUL("n", "mvinv", "iNorm")
/* Calculate the vector from the vertex to the light in eye
* coordinates.
*/
"SUB lightVec, lightPos, V;\n"
NORMALIZE("lightVec", "lightVec")
/* Compute diffuse lighting coefficient.
*/
"DP3 NdotL.x, n, lightVec;\n"
"MAX NdotL.x, NdotL.x, {0.0};\n"
"MIN NdotL.x, NdotL.x, {1.0};\n"
/* Accumulate color contributions.
*/
"MOV oColor, diffuseCol;\n"
"MAD oColor.xyz, NdotL.x, diffuseCol, ambientCol;\n"
"END\n"
;
static const char frag_code[] =
"!!ARBfp1.0\n"
"TEMP shadow, temp;\n"
"TXP shadow, fragment.texcoord[0], texture[0], 2D;\n"
"RCP temp.x, fragment.texcoord[0].w;\n"
"MUL temp.x, temp.x, fragment.texcoord[0].z;\n"
"SGE shadow, shadow.x, temp.x;\n"
"MUL result.color.rgb, fragment.color, shadow.x;\n"
"MOV result.color.a, fragment.color;\n"
"END\n"
;
static const char frag_shadow_code[] =
"!!ARBfp1.0\n"
"OPTION ARB_fragment_program_shadow;\n"
"TEMP shadow;\n"
"TXP shadow, fragment.texcoord[0], texture[0], SHADOW2D;\n"
"MUL result.color.rgb, fragment.color, shadow.x;\n"
"MOV result.color.a, fragment.color.a;\n"
"END\n"
;
static void
DrawScene(void)
{
@ -134,27 +252,56 @@ DrawScene(void)
}
/*
* Load the GL_TEXTURE matrix with the projection from the light
* source's point of view.
/**
* Calculate modelview and project matrices for the light
*
* Stores the results in \c lightProjection (projection matrix) and
* \c lightModelview (modelview matrix).
*/
static void
MakeShadowMatrix(const GLfloat lightPos[4], const GLfloat spotDir[3],
GLfloat spotAngle, GLfloat shadowNear, GLfloat shadowFar)
{
GLfloat d;
glMatrixMode(GL_TEXTURE);
/* compute frustum to enclose spot light cone */
const GLfloat d = shadowNear * tan(spotAngle);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glTranslatef(0.5, 0.5, 0.5 + Bias);
glScalef(0.5, 0.5, 0.5);
d = shadowNear * tan(spotAngle);
glFrustum(-d, d, -d, d, shadowNear, shadowFar);
glGetFloatv(GL_PROJECTION_MATRIX, lightProjection);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
gluLookAt(lightPos[0], lightPos[1], lightPos[2],
lightPos[0] + spotDir[0],
lightPos[1] + spotDir[1],
lightPos[2] + spotDir[2],
0, 1, 0);
0.0, 1.0, 0.0);
glGetFloatv(GL_MODELVIEW_MATRIX, lightModelview);
glPopMatrix();
}
/**
* Load \c GL_TEXTURE matrix with light's MVP matrix.
*/
static void SetShadowTextureMatrix(void)
{
static const GLfloat biasMatrix[16] = {
0.5, 0.0, 0.0, 0.0,
0.0, 0.5, 0.0, 0.0,
0.0, 0.0, 0.5, 0.0,
0.5, 0.5, 0.5, 1.0,
};
glMatrixMode(GL_TEXTURE);
glLoadMatrixf(biasMatrix);
glTranslatef(0.0, 0.0, Bias);
glMultMatrixf(lightProjection);
glMultMatrixf(lightModelview);
glMatrixMode(GL_MODELVIEW);
}
@ -258,7 +405,6 @@ RenderShadowMap(void)
{
GLenum depthFormat; /* GL_DEPTH_COMPONENT or GL_DEPTH_STENCIL_EXT */
GLenum depthType; /* GL_UNSIGNED_INT_24_8_EXT or GL_UNSIGNED_INT */
float d;
if (WindowWidth >= 1024 && WindowHeight >= 1024) {
ShadowTexWidth = ShadowTexHeight = 1024;
@ -283,17 +429,11 @@ RenderShadowMap(void)
depthType = GL_UNSIGNED_INT;
}
/* compute frustum to enclose spot light cone */
d = ShadowNear * tan(SpotAngle);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-d, d, -d, d, ShadowNear, ShadowFar);
glLoadMatrixf(lightProjection);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(LightPos[0], LightPos[1], LightPos[2], /* from */
0, 0, 0, /* target */
0, 1, 0); /* up */
glLoadMatrixf(lightModelview);
if (UseFBO) {
GLenum fbo_status;
@ -389,10 +529,8 @@ ShowShadowMap(void)
DisableTexgen();
/* interpret texture's depth values as luminance values */
#if defined(GL_ARB_shadow)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE);
#endif
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glBegin(GL_POLYGON);
@ -420,6 +558,7 @@ Display(void)
LightPos, SpotDir);
if (NeedNewShadowMap) {
MakeShadowMatrix(LightPos, SpotDir, SpotAngle, ShadowNear, ShadowFar);
RenderShadowMap();
NeedNewShadowMap = GL_FALSE;
}
@ -457,12 +596,11 @@ Display(void)
}
if (DisplayMode == SHOW_DEPTH_MAPPING) {
#if defined(GL_ARB_shadow)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
#endif
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glEnable(GL_TEXTURE_2D);
MakeShadowMatrix(LightPos, SpotDir, SpotAngle, ShadowNear, ShadowFar);
SetShadowTextureMatrix();
EnableIdentityTexgen();
}
else if (DisplayMode == SHOW_DISTANCE) {
@ -476,20 +614,42 @@ Display(void)
}
else {
assert(DisplayMode == SHOW_SHADOWS);
#if defined(GL_ARB_shadow)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB,
GL_COMPARE_R_TO_TEXTURE_ARB);
#endif
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
if (curr_frag > 0) {
glEnable(GL_FRAGMENT_PROGRAM_ARB);
}
else {
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
glEnable(GL_TEXTURE_2D);
MakeShadowMatrix(LightPos, SpotDir, SpotAngle, ShadowNear, ShadowFar);
EnableIdentityTexgen();
SetShadowTextureMatrix();
if (UseVP) {
glEnable(GL_VERTEX_PROGRAM_ARB);
}
else {
glEnable(GL_LIGHTING);
EnableIdentityTexgen();
}
}
DrawScene();
DisableTexgen();
glDisable(GL_TEXTURE_1D);
if (UseVP) {
glDisable(GL_VERTEX_PROGRAM_ARB);
}
else {
DisableTexgen();
glDisable(GL_LIGHTING);
}
if (curr_frag > 0) {
glDisable(GL_FRAGMENT_PROGRAM_ARB);
}
glDisable(GL_TEXTURE_2D);
}
@ -561,6 +721,14 @@ Key(unsigned char key, int x, int y)
case 'm':
DisplayMode = SHOW_DEPTH_MAPPING;
break;
case 'M':
curr_frag = (1 + curr_frag) % max_frag;
printf("Using fragment %s\n", FragProgNames[curr_frag]);
if (HaveFP) {
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, frag_progs[curr_frag]);
}
break;
case 'n':
case 's':
case ' ':
@ -572,10 +740,8 @@ Key(unsigned char key, int x, int y)
if (Operator >= 8)
Operator = 0;
printf("Operator: %s\n", OperatorName[Operator]);
#if defined(GL_ARB_shadow)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB,
OperatorFunc[Operator]);
#endif
}
break;
case 'p':
@ -592,6 +758,11 @@ Key(unsigned char key, int x, int y)
NeedNewShadowMap = GL_TRUE;
}
break;
case 'v':
UseVP = !UseVP && HaveVP;
printf("Using vertex %s mode.\n",
UseVP ? "program" : "fixed-function");
break;
case 'z':
Zrot -= step;
break;
@ -646,28 +817,62 @@ SpecialKey(int key, int x, int y)
}
/* A helper for finding errors in program strings */
static int FindLine( const char *program, int position )
{
int i, line = 1;
for (i = 0; i < position; i++) {
if (program[i] == '\n')
line++;
}
return line;
}
static GLuint
compile_program(GLenum target, const char *code)
{
GLuint p;
GLint errorPos;
glGenProgramsARB(1, & p);
glBindProgramARB(target, p);
glProgramStringARB(target, GL_PROGRAM_FORMAT_ASCII_ARB,
strlen(code), code);
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
if (glGetError() != GL_NO_ERROR || errorPos != -1) {
int l = FindLine(code, errorPos);
printf("Fragment Program Error (pos=%d line=%d): %s\n", errorPos, l,
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
exit(0);
}
glBindProgramARB(target, 0);
return p;
}
static void
Init(void)
{
static const GLfloat borderColor[4] = {1.0, 0.0, 0.0, 0.0};
#if defined(GL_ARB_depth_texture) && defined(GL_ARB_shadow)
if (!glutExtensionSupported("GL_ARB_depth_texture") ||
!glutExtensionSupported("GL_ARB_shadow")) {
#else
if (1) {
#endif
printf("Sorry, this demo requires the GL_ARB_depth_texture and GL_ARB_shadow extensions\n");
exit(1);
}
printf("Using GL_ARB_depth_texture and GL_ARB_shadow\n");
#if defined(GL_ARB_shadow_ambient)
HaveVP = glutExtensionSupported("GL_ARB_vertex_program");
HaveFP = glutExtensionSupported("GL_ARB_fragment_program");
HaveFP_Shadow = glutExtensionSupported("GL_ARB_fragment_program_shadow");
HaveShadowAmbient = glutExtensionSupported("GL_ARB_shadow_ambient");
if (HaveShadowAmbient) {
printf("and GL_ARB_shadow_ambient\n");
}
#endif
HaveEXTshadowFuncs = glutExtensionSupported("GL_EXT_shadow_funcs");
@ -690,15 +895,12 @@ Init(void)
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
#if defined(GL_ARB_shadow)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB,
GL_COMPARE_R_TO_TEXTURE_ARB);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);
#endif
if (HaveShadowAmbient) {
#if defined(GL_ARB_shadow_ambient)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FAIL_VALUE_ARB, 0.3);
#endif
}
#if defined(GL_EXT_framebuffer_object)
@ -733,6 +935,25 @@ Init(void)
256, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, image);
}
if (HaveVP) {
vert_prog = compile_program(GL_VERTEX_PROGRAM_ARB, vert_code);
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vert_prog);
}
max_frag = 1;
frag_progs[0] = 0;
if (HaveFP) {
frag_progs[1] = compile_program(GL_FRAGMENT_PROGRAM_ARB, frag_code);
max_frag = 2;
}
if (HaveFP && HaveFP_Shadow) {
frag_progs[2] = compile_program(GL_FRAGMENT_PROGRAM_ARB,
frag_shadow_code);
max_frag = 3;
}
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
@ -751,6 +972,8 @@ PrintHelp(void)
printf(" f = toggle nearest/bilinear texture filtering\n");
printf(" b/B = decrease/increase shadow map Z bias\n");
printf(" p = toggle use of packed depth/stencil\n");
printf(" M = cycle through fragment program modes\n");
printf(" v = toggle vertex program modes\n");
printf(" cursor keys = rotate scene\n");
printf(" <shift> + cursor keys = rotate light source\n");
if (HaveEXTshadowFuncs)

View file

@ -23,6 +23,7 @@ SOURCES = \
arbvptest3.c \
arbvptorus.c \
arbvpwarpmesh.c \
arraytexture.c \
blendminmax.c \
blendsquare.c \
bufferobj.c \
@ -117,6 +118,12 @@ getprocaddress: getprocaddress.c getproclist.h
getproclist.h: $(TOP)/src/mesa/glapi/gl_API.xml getprocaddress.c getprocaddress.py
python getprocaddress.py > getproclist.h
arraytexture: arraytexture.o readtex.o
$(CC) $(CFLAGS) arraytexture.o readtex.o $(LIBS) -o $@
arraytexture.o: arraytexture.c readtex.h
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
afsmultiarb: afsmultiarb.o readtex.o
$(CC) $(CFLAGS) afsmultiarb.o readtex.o $(LIBS) -o $@

337
progs/tests/arraytexture.c Normal file
View file

@ -0,0 +1,337 @@
/*
* (C) Copyright IBM Corporation 2007
* 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
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* IBM 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 arraytexture.c
*
*
* \author Ian Romanick <idr@us.ibm.com>
*/
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <GL/glut.h>
#include <GL/glext.h>
#if !defined(GL_EXT_texture_array) && !defined(GL_MESA_texture_array)
# error "This demo requires enums for either GL_EXT_texture_array or GL_MESA_texture_array to build."
#endif
#include "readtex.h"
#define GL_CHECK_ERROR() \
do { \
GLenum err = glGetError(); \
if (err) { \
printf("%s:%u: %s (0x%04x)\n", __FILE__, __LINE__, \
gluErrorString(err), err); \
} \
} while (0)
static const char *const textures[] = {
"../images/girl.rgb",
"../images/girl2.rgb",
"../images/arch.rgb",
"../images/s128.rgb",
"../images/tree3.rgb",
"../images/bw.rgb",
"../images/reflect.rgb",
"../images/wrs_logo.rgb",
NULL
};
static const char frag_prog[] =
"!!ARBfp1.0\n"
"OPTION MESA_texture_array;\n"
"TEX result.color, fragment.texcoord[0], texture[0], ARRAY2D;\n"
"END\n";
static GLfloat Xrot = 0, Yrot = -30, Zrot = 0;
static GLfloat texZ = 0.0;
static GLfloat texZ_dir = 0.01;
static GLint num_layers;
static PFNGLBINDPROGRAMARBPROC bind_program;
static PFNGLPROGRAMSTRINGARBPROC program_string;
static PFNGLGENPROGRAMSARBPROC gen_programs;
static void
PrintString(const char *s)
{
while (*s) {
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int) *s);
s++;
}
}
static void Idle(void)
{
static int lastTime = 0;
int t = glutGet(GLUT_ELAPSED_TIME);
if (lastTime == 0)
lastTime = t;
else if (t - lastTime < 10)
return;
lastTime = t;
texZ += texZ_dir;
if ((texZ < 0.0) || ((GLint) texZ > num_layers)) {
texZ_dir = -texZ_dir;
}
glutPostRedisplay();
}
static void Display(void)
{
char str[100];
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1, 1, -1, 1, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
(*bind_program)(GL_FRAGMENT_PROGRAM_ARB, 0);
glColor3f(1,1,1);
glRasterPos3f(-0.9, -0.9, 0.0);
sprintf(str, "Texture Z coordinate = %4.1f", texZ);
PrintString(str);
(*bind_program)(GL_FRAGMENT_PROGRAM_ARB, 1);
GL_CHECK_ERROR();
glEnable(GL_TEXTURE_2D_ARRAY_EXT);
GL_CHECK_ERROR();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, -8.0);
glPushMatrix();
glRotatef(Xrot, 1, 0, 0);
glRotatef(Yrot, 0, 1, 0);
glRotatef(Zrot, 0, 0, 1);
glBegin(GL_QUADS);
glTexCoord3f(0.0, 0.0, texZ); glVertex2f(-1.0, -1.0);
glTexCoord3f(2.0, 0.0, texZ); glVertex2f(1.0, -1.0);
glTexCoord3f(2.0, 2.0, texZ); glVertex2f(1.0, 1.0);
glTexCoord3f(0.0, 2.0, texZ); glVertex2f(-1.0, 1.0);
glEnd();
glPopMatrix();
glDisable(GL_TEXTURE_2D_ARRAY_EXT);
GL_CHECK_ERROR();
(*bind_program)(GL_FRAGMENT_PROGRAM_ARB, 0);
GL_CHECK_ERROR();
glutSwapBuffers();
}
static void Reshape(int width, int height)
{
glViewport(0, 0, width, height);
}
static void Key(unsigned char key, int x, int y)
{
(void) x;
(void) y;
switch (key) {
case 27:
exit(0);
break;
}
glutPostRedisplay();
}
static void SpecialKey(int key, int x, int y)
{
const GLfloat step = 3.0;
(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 int FindLine(const char *program, int position)
{
int i, line = 1;
for (i = 0; i < position; i++) {
if (program[i] == '\n')
line++;
}
return line;
}
static void
compile_fragment_program(GLuint id, const char *prog)
{
int errorPos;
int err;
err = glGetError();
(*bind_program)(GL_FRAGMENT_PROGRAM_ARB, id);
(*program_string)(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
strlen(prog), (const GLubyte *) prog);
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
err = glGetError();
if (err != GL_NO_ERROR || errorPos != -1) {
int l = FindLine(prog, errorPos);
printf("Fragment Program Error (err=%d, pos=%d line=%d): %s\n",
err, errorPos, l,
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
exit(0);
}
}
static void require_extension(const char *ext)
{
if (!glutExtensionSupported(ext)) {
printf("Sorry, %s not supported by this renderer.\n", ext);
exit(1);
}
}
static void Init(void)
{
const char *const ver_string = (const char *const) glGetString(GL_VERSION);
unsigned i;
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
printf("GL_VERSION = %s\n", ver_string);
require_extension("GL_ARB_fragment_program");
require_extension("GL_MESA_texture_array");
require_extension("GL_SGIS_generate_mipmap");
bind_program = glutGetProcAddress("glBindProgramARB");
program_string = glutGetProcAddress("glProgramStringARB");
gen_programs = glutGetProcAddress("glGenProgramsARB");
for (num_layers = 0; textures[num_layers] != NULL; num_layers++)
/* empty */ ;
glBindTexture(GL_TEXTURE_2D_ARRAY_EXT, 1);
glTexImage3D(GL_TEXTURE_2D_ARRAY_EXT, 0, GL_RGB8,
256, 256, num_layers, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
GL_CHECK_ERROR();
glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_GENERATE_MIPMAP_SGIS,
GL_TRUE);
for (i = 0; textures[i] != NULL; i++) {
GLint width, height;
GLenum format;
GLubyte *image = LoadRGBImage(textures[i], &width, &height, &format);
if (!image) {
printf("Error: could not load texture image %s\n", textures[i]);
exit(1);
}
/* resize to 256 x 256 */
if (width != 256 || height != 256) {
GLubyte *newImage = malloc(256 * 256 * 4);
gluScaleImage(format, width, height, GL_UNSIGNED_BYTE, image,
256, 256, GL_UNSIGNED_BYTE, newImage);
free(image);
image = newImage;
}
glTexSubImage3D(GL_TEXTURE_2D_ARRAY_EXT, 0,
0, 0, i, 256, 256, 1,
format, GL_UNSIGNED_BYTE, image);
free(image);
}
GL_CHECK_ERROR();
glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
GL_CHECK_ERROR();
glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
GL_CHECK_ERROR();
compile_fragment_program(1, frag_prog);
GL_CHECK_ERROR();
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowPosition(0, 0);
glutInitWindowSize(350, 350);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutCreateWindow("Array texture test");
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
glutSpecialFunc(SpecialKey);
glutDisplayFunc(Display);
glutIdleFunc(Idle);
Init();
glutMainLoop();
return 0;
}

View file

@ -23,6 +23,7 @@ PROGS = glthreads \
overlay \
pbinfo \
pbdemo \
texture_from_pixmap \
wincopy \
xfont \
xrotfontdemo \

View file

@ -0,0 +1,396 @@
/*
* Mesa 3-D graphics library
* Version: 7.1
*
* 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"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* Test the GLX_EXT_texture_from_pixmap extension
* Brian Paul
* 19 May 2007
*/
#define GL_GLEXT_PROTOTYPES
#define GLX_GLXEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glx.h>
#include <X11/keysym.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
static float top, bottom;
static PFNGLXBINDTEXIMAGEEXTPROC glXBindTexImageEXT_func = NULL;
static PFNGLXRELEASETEXIMAGEEXTPROC glXReleaseTexImageEXT_func = NULL;
static Display *
OpenDisplay(void)
{
int screen;
Display *dpy;
const char *ext;
dpy = XOpenDisplay(NULL);
if (!dpy) {
printf("Couldn't open default display!\n");
exit(1);
}
screen = DefaultScreen(dpy);
ext = glXQueryExtensionsString(dpy, screen);
if (!strstr(ext, "GLX_EXT_texture_from_pixmap")) {
fprintf(stderr, "GLX_EXT_texture_from_pixmap not supported.\n");
exit(1);
}
glXBindTexImageEXT_func = (PFNGLXBINDTEXIMAGEEXTPROC)
glXGetProcAddress((GLubyte *) "glXBindTexImageEXT");
glXReleaseTexImageEXT_func = (PFNGLXRELEASETEXIMAGEEXTPROC)
glXGetProcAddress((GLubyte*) "glXReleaseTexImageEXT");
if (!glXBindTexImageEXT_func || !glXReleaseTexImageEXT_func) {
fprintf(stderr, "glXGetProcAddress failed!\n");
exit(1);
}
return dpy;
}
static GLXFBConfig
ChoosePixmapFBConfig(Display *display)
{
int screen = DefaultScreen(display);
GLXFBConfig *fbconfigs;
int i, nfbconfigs, value;
fbconfigs = glXGetFBConfigs(display, screen, &nfbconfigs);
for (i = 0; i < nfbconfigs; i++) {
glXGetFBConfigAttrib(display, fbconfigs[i], GLX_DRAWABLE_TYPE, &value);
if (!(value & GLX_PIXMAP_BIT))
continue;
glXGetFBConfigAttrib(display, fbconfigs[i],
GLX_BIND_TO_TEXTURE_TARGETS_EXT, &value);
if (!(value & GLX_TEXTURE_2D_BIT_EXT))
continue;
glXGetFBConfigAttrib(display, fbconfigs[i],
GLX_BIND_TO_TEXTURE_RGBA_EXT, &value);
if (value == False) {
glXGetFBConfigAttrib(display, fbconfigs[i],
GLX_BIND_TO_TEXTURE_RGB_EXT, &value);
if (value == False)
continue;
}
glXGetFBConfigAttrib(display, fbconfigs[i],
GLX_Y_INVERTED_EXT, &value);
if (value == True) {
top = 0.0f;
bottom = 1.0f;
}
else {
top = 1.0f;
bottom = 0.0f;
}
break;
}
if (i == nfbconfigs) {
printf("Unable to find FBconfig for texturing\n");
exit(1);
}
return fbconfigs[i];
}
static GLXPixmap
CreatePixmap(Display *dpy, GLXFBConfig config, int w, int h, Pixmap *p)
{
GLXPixmap gp;
const int pixmapAttribs[] = {
GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGB_EXT,
None
};
Window root = RootWindow(dpy, 0);
*p = XCreatePixmap(dpy, root, w, h, 24);
XSync(dpy, 0);
gp = glXCreatePixmap(dpy, config, *p, pixmapAttribs);
XSync(dpy, 0);
return gp;
}
static void
DrawPixmapImage(Display *dpy, Pixmap pm, int w, int h)
{
XGCValues gcvals;
GC gc;
gcvals.background = 0;
gc = XCreateGC(dpy, pm, GCBackground, &gcvals);
XSetForeground(dpy, gc, 0x0);
XFillRectangle(dpy, pm, gc, 0, 0, w, h);
XSetForeground(dpy, gc, 0xff0000);
XFillRectangle(dpy, pm, gc, 0, 0, 50, 50);
XSetForeground(dpy, gc, 0x00ff00);
XFillRectangle(dpy, pm, gc, w - 50, 0, 50, 50);
XSetForeground(dpy, gc, 0x0000ff);
XFillRectangle(dpy, pm, gc, 0, h - 50, 50, 50);
XSetForeground(dpy, gc, 0xffffff);
XFillRectangle(dpy, pm, gc, h - 50, h - 50, 50, 50);
XSetForeground(dpy, gc, 0xffff00);
XSetLineAttributes(dpy, gc, 3, LineSolid, CapButt, JoinBevel);
XDrawLine(dpy, pm, gc, 0, 0, w, h);
XDrawLine(dpy, pm, gc, 0, h, w, 0);
XFreeGC(dpy, gc);
}
static XVisualInfo *
ChooseWindowVisual(Display *dpy)
{
int screen = DefaultScreen(dpy);
XVisualInfo *visinfo;
int attribs[] = {
GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER,
None
};
visinfo = glXChooseVisual(dpy, screen, attribs);
if (!visinfo) {
printf("Unable to find RGB, double-buffered visual\n");
exit(1);
}
return visinfo;
}
static Window
CreateWindow(Display *dpy, XVisualInfo *visinfo,
int width, int height, const char *name)
{
int screen = DefaultScreen(dpy);
Window win;
XSetWindowAttributes attr;
unsigned long mask;
Window root;
root = RootWindow(dpy, screen);
/* window attributes */
attr.background_pixel = 0;
attr.border_pixel = 0;
attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
win = XCreateWindow(dpy, root, 0, 0, width, height,
0, visinfo->depth, InputOutput,
visinfo->visual, mask, &attr);
if (win) {
XSizeHints sizehints;
sizehints.width = width;
sizehints.height = height;
sizehints.flags = USSize;
XSetNormalHints(dpy, win, &sizehints);
XSetStandardProperties(dpy, win, name, name,
None, (char **)NULL, 0, &sizehints);
XMapWindow(dpy, win);
}
return win;
}
static void
BindPixmapTexture(Display *dpy, GLXPixmap gp)
{
GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glXBindTexImageEXT_func(dpy, gp, GLX_FRONT_LEFT_EXT, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glEnable(GL_TEXTURE_2D);
/*
glXReleaseTexImageEXT_func(display, glxpixmap, GLX_FRONT_LEFT_EXT);
*/
}
static void
Resize(Window win, unsigned int width, unsigned int height)
{
float sz = 1.5;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-sz, sz, -sz, sz, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
}
static void
Redraw(Display *dpy, Window win, float rot)
{
glClearColor(0.25, 0.25, 0.25, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rot, 0, 0, 1);
glRotatef(2.0 * rot, 1, 0, 0);
glBegin(GL_QUADS);
glTexCoord2d(0.0, bottom);
glVertex2f(-1, -1);
glTexCoord2d(1.0, bottom);
glVertex2f( 1, -1);
glTexCoord2d(1.0, top);
glVertex2d(1.0, 1.0);
glTexCoord2d(0.0, top);
glVertex2f(-1.0, 1.0);
glEnd();
glPopMatrix();
glXSwapBuffers(dpy, win);
}
static void
EventLoop(Display *dpy, Window win)
{
GLfloat rot = 0.0;
int anim = 0;
while (1) {
if (!anim || XPending(dpy) > 0) {
XEvent event;
XNextEvent(dpy, &event);
switch (event.type) {
case Expose:
Redraw(dpy, win, rot);
break;
case ConfigureNotify:
Resize(event.xany.window,
event.xconfigure.width,
event.xconfigure.height);
break;
case KeyPress:
{
char buf[100];
KeySym keySym;
XComposeStatus stat;
XLookupString(&event.xkey, buf, sizeof(buf), &keySym, &stat);
if (keySym == XK_Escape) {
return; /* exit */
}
else if (keySym == XK_r) {
rot += 1.0;
Redraw(dpy, win, rot);
}
else if (keySym == XK_a) {
anim = !anim;
}
else if (keySym == XK_R) {
rot -= 1.0;
Redraw(dpy, win, rot);
}
}
break;
default:
; /*no-op*/
}
}
else {
/* animate */
rot += 1.0;
Redraw(dpy, win, rot);
}
}
}
int
main(int argc, char *argv[])
{
Display *dpy;
GLXFBConfig pixmapConfig;
XVisualInfo *windowVis;
GLXPixmap gp;
Window win;
GLXContext ctx;
Pixmap p;
dpy = OpenDisplay();
pixmapConfig = ChoosePixmapFBConfig(dpy);
windowVis = ChooseWindowVisual(dpy);
win = CreateWindow(dpy, windowVis, 500, 500, "Texture From Pixmap");
gp = CreatePixmap(dpy, pixmapConfig, 512, 512, &p);
DrawPixmapImage(dpy, p, 512, 512);
ctx = glXCreateContext(dpy, windowVis, NULL, True);
if (!ctx) {
printf("Couldn't create GLX context\n");
exit(1);
}
glXMakeCurrent(dpy, win, ctx);
BindPixmapTexture(dpy, gp);
EventLoop(dpy, win);
return 0;
}

View file

@ -2434,6 +2434,7 @@ void (*glXGetProcAddress(const GLubyte *procname))( void )
return _glapi_get_proc_address((const char *) procname);
}
void (*glXGetProcAddressARB(const GLubyte *procName))( void ) __attribute__ ((alias ("glXGetProcAddress")));
/**
* \brief Query the Mini GLX version.

View file

@ -40,18 +40,6 @@
#include "glcontextmodes.h"
#include "glheader.h"
static void ChangeDrawableAttribute( Display * dpy, GLXDrawable drawable,
const CARD32 * attribs, size_t num_attribs );
static void DestroyPbuffer( Display * dpy, GLXDrawable drawable );
static GLXDrawable CreatePbuffer( Display *dpy,
const __GLcontextModes * fbconfig, unsigned int width, unsigned int height,
const int *attrib_list, GLboolean size_in_attribs );
static int GetDrawableAttribute( Display *dpy, GLXDrawable drawable,
int attribute, unsigned int *value );
/**
* Change a drawable's attribute.
@ -150,7 +138,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

@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
* Version: 6.5.3
* Version: 7.1
*
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
@ -292,3 +292,97 @@ _mesa_init_glsl_driver_functions(struct dd_function_table *driver)
driver->UseProgram = _mesa_use_program;
driver->ValidateProgram = _mesa_validate_program;
}
/**
* Call the ctx->Driver.* state functions with current values to initialize
* driver state.
* Only the Intel drivers use this so far.
*/
void
_mesa_init_driver_state(GLcontext *ctx)
{
ctx->Driver.AlphaFunc(ctx, ctx->Color.AlphaFunc, ctx->Color.AlphaRef);
ctx->Driver.BlendColor(ctx, ctx->Color.BlendColor);
ctx->Driver.BlendEquationSeparate(ctx,
ctx->Color.BlendEquationRGB,
ctx->Color.BlendEquationA);
ctx->Driver.BlendFuncSeparate(ctx,
ctx->Color.BlendSrcRGB,
ctx->Color.BlendDstRGB,
ctx->Color.BlendSrcA, ctx->Color.BlendDstA);
ctx->Driver.ColorMask(ctx,
ctx->Color.ColorMask[RCOMP],
ctx->Color.ColorMask[GCOMP],
ctx->Color.ColorMask[BCOMP],
ctx->Color.ColorMask[ACOMP]);
ctx->Driver.CullFace(ctx, ctx->Polygon.CullFaceMode);
ctx->Driver.DepthFunc(ctx, ctx->Depth.Func);
ctx->Driver.DepthMask(ctx, ctx->Depth.Mask);
ctx->Driver.Enable(ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled);
ctx->Driver.Enable(ctx, GL_BLEND, ctx->Color.BlendEnabled);
ctx->Driver.Enable(ctx, GL_COLOR_LOGIC_OP, ctx->Color.ColorLogicOpEnabled);
ctx->Driver.Enable(ctx, GL_COLOR_SUM, ctx->Fog.ColorSumEnabled);
ctx->Driver.Enable(ctx, GL_CULL_FACE, ctx->Polygon.CullFlag);
ctx->Driver.Enable(ctx, GL_DEPTH_TEST, ctx->Depth.Test);
ctx->Driver.Enable(ctx, GL_DITHER, ctx->Color.DitherFlag);
ctx->Driver.Enable(ctx, GL_FOG, ctx->Fog.Enabled);
ctx->Driver.Enable(ctx, GL_LIGHTING, ctx->Light.Enabled);
ctx->Driver.Enable(ctx, GL_LINE_SMOOTH, ctx->Line.SmoothFlag);
ctx->Driver.Enable(ctx, GL_POLYGON_STIPPLE, ctx->Polygon.StippleFlag);
ctx->Driver.Enable(ctx, GL_SCISSOR_TEST, ctx->Scissor.Enabled);
ctx->Driver.Enable(ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled);
ctx->Driver.Enable(ctx, GL_TEXTURE_1D, GL_FALSE);
ctx->Driver.Enable(ctx, GL_TEXTURE_2D, GL_FALSE);
ctx->Driver.Enable(ctx, GL_TEXTURE_RECTANGLE_NV, GL_FALSE);
ctx->Driver.Enable(ctx, GL_TEXTURE_3D, GL_FALSE);
ctx->Driver.Enable(ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE);
ctx->Driver.Fogfv(ctx, GL_FOG_COLOR, ctx->Fog.Color);
ctx->Driver.Fogfv(ctx, GL_FOG_MODE, 0);
ctx->Driver.Fogfv(ctx, GL_FOG_DENSITY, &ctx->Fog.Density);
ctx->Driver.Fogfv(ctx, GL_FOG_START, &ctx->Fog.Start);
ctx->Driver.Fogfv(ctx, GL_FOG_END, &ctx->Fog.End);
ctx->Driver.FrontFace(ctx, ctx->Polygon.FrontFace);
{
GLfloat f = (GLfloat) ctx->Light.Model.ColorControl;
ctx->Driver.LightModelfv(ctx, GL_LIGHT_MODEL_COLOR_CONTROL, &f);
}
ctx->Driver.LineWidth(ctx, ctx->Line.Width);
ctx->Driver.LogicOpcode(ctx, ctx->Color.LogicOp);
ctx->Driver.PointSize(ctx, ctx->Point.Size);
ctx->Driver.PolygonStipple(ctx, (const GLubyte *) ctx->PolygonStipple);
ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
ctx->Scissor.Width, ctx->Scissor.Height);
ctx->Driver.ShadeModel(ctx, ctx->Light.ShadeModel);
ctx->Driver.StencilFuncSeparate(ctx, GL_FRONT,
ctx->Stencil.Function[0],
ctx->Stencil.Ref[0],
ctx->Stencil.ValueMask[0]);
ctx->Driver.StencilFuncSeparate(ctx, GL_BACK,
ctx->Stencil.Function[1],
ctx->Stencil.Ref[1],
ctx->Stencil.ValueMask[1]);
ctx->Driver.StencilMaskSeparate(ctx, GL_FRONT, ctx->Stencil.WriteMask[0]);
ctx->Driver.StencilMaskSeparate(ctx, GL_BACK, ctx->Stencil.WriteMask[1]);
ctx->Driver.StencilOpSeparate(ctx, GL_FRONT,
ctx->Stencil.FailFunc[0],
ctx->Stencil.ZFailFunc[0],
ctx->Stencil.ZPassFunc[0]);
ctx->Driver.StencilOpSeparate(ctx, GL_BACK,
ctx->Stencil.FailFunc[1],
ctx->Stencil.ZFailFunc[1],
ctx->Stencil.ZPassFunc[1]);
ctx->Driver.DrawBuffer(ctx, ctx->Color.DrawBuffer[0]);
}

View file

@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
* Version: 6.5.3
* Version: 7.1
*
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
@ -33,4 +33,9 @@ _mesa_init_driver_functions(struct dd_function_table *driver);
extern void
_mesa_init_glsl_driver_functions(struct dd_function_table *driver);
extern void
_mesa_init_driver_state(GLcontext *ctx);
#endif

View file

@ -32,7 +32,7 @@ install:
clean:
@for dir in $(DRI_DIRS) ; do \
if [ -d $$dir ] ; then \
(cd $$dir && $(MAKE) clean ; \
(cd $$dir && $(MAKE) clean) ; \
fi \
done
-rm -f common/*.o

View file

@ -25,6 +25,7 @@ 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
@ -55,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 #####
@ -71,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)
@ -85,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) \
@ -104,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

@ -995,6 +995,9 @@ __driUtilCreateNewScreen(__DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
psc->getMSC = driGetMSC;
psc->createNewContext = driCreateNewContext;
if (internal_api_version >= 20070121)
psc->setTexOffset = psp->DriverAPI.setTexOffset;
if ( (psp->DriverAPI.InitDriver != NULL)
&& !(*psp->DriverAPI.InitDriver)(psp) ) {
_mesa_free( psp );

View file

@ -189,6 +189,12 @@ struct __DriverAPIRec {
/*@}*/
void (*CopySubBuffer)(__DRIdrawablePrivate *driDrawPriv,
int x, int y, int w, int h);
/**
* See corresponding field in \c __DRIscreenRec.
*/
void (*setTexOffset)(__DRIcontext *pDRICtx, GLint texname,
unsigned long long offset, GLint depth, GLuint pitch);
};

View file

@ -440,6 +440,13 @@ static const char Color4ubVertex3fvSUN_names[] =
"";
#endif
#if defined(need_GL_EXT_texture_array)
static const char FramebufferTextureLayerEXT_names[] =
"iiiii\0" /* Parameter signature */
"glFramebufferTextureLayerEXT\0"
"";
#endif
#if defined(need_GL_SGIX_list_priority)
static const char GetListParameterivSGIX_names[] =
"iip\0" /* Parameter signature */
@ -5479,6 +5486,13 @@ static const struct dri_extension_function GL_EXT_texture3D_functions[] = {
};
#endif
#if defined(need_GL_EXT_texture_array)
static const struct dri_extension_function GL_EXT_texture_array_functions[] = {
{ FramebufferTextureLayerEXT_names, FramebufferTextureLayerEXT_remap_index, -1 },
{ NULL, 0, 0 }
};
#endif
#if defined(need_GL_EXT_texture_object)
static const struct dri_extension_function GL_EXT_texture_object_functions[] = {
{ PrioritizeTextures_names, -1, 331 },

View file

@ -138,10 +138,10 @@ static void ffb_translate_vertex(GLcontext *ctx, const ffb_vertex *src,
const GLfloat ty = m[13];
const GLfloat tz = m[14];
dst->win[0] = sx * src->x + tx;
dst->win[1] = sy * src->y + ty;
dst->win[2] = sz * src->z + tz;
dst->win[3] = 1.0;
dst->attrib[FRAG_ATTRIB_WPOS][0] = sx * src->x + tx;
dst->attrib[FRAG_ATTRIB_WPOS][1] = sy * src->y + ty;
dst->attrib[FRAG_ATTRIB_WPOS][2] = sz * src->z + tz;
dst->attrib[FRAG_ATTRIB_WPOS][3] = 1.0;
dst->color[0] = FFB_UBYTE_FROM_COLOR(src->color[0].red);
dst->color[1] = FFB_UBYTE_FROM_COLOR(src->color[0].green);

View file

@ -34,6 +34,8 @@
#include "texmem.h"
#include "drivers/common/driverfuncs.h"
#include "intel_screen.h"
#include "intel_batchbuffer.h"
@ -1074,7 +1076,7 @@ void i830InitState( i830ContextPtr i830 )
i830_init_packets( i830 );
intelInitState( ctx );
_mesa_init_driver_state(ctx);
memcpy( &i830->initial, &i830->state, sizeof(i830->state) );
@ -1085,8 +1087,3 @@ void i830InitState( i830ContextPtr i830 )
I830_UPLOAD_CTX |
I830_UPLOAD_BUFFERS);
}

View file

@ -857,11 +857,6 @@ static void i915BindProgram( GLcontext *ctx,
assert(p->on_hardware == 0);
assert(p->params_uptodate == 0);
/* Hack: make sure fog is correctly enabled according to this
* fragment program's fog options.
*/
ctx->Driver.Enable( ctx, GL_FRAGMENT_PROGRAM_ARB,
ctx->FragmentProgram.Enabled );
}
}
@ -935,9 +930,6 @@ static void i915ProgramStringNotify( GLcontext *ctx,
/* Hack: make sure fog is correctly enabled according to this
* fragment program's fog options.
*/
ctx->Driver.Enable( ctx, GL_FRAGMENT_PROGRAM_ARB,
ctx->FragmentProgram.Enabled );
if (p->FragProg.FogOption) {
/* add extra instructions to do fog, then turn off FogOption field */
_mesa_append_fog_code(ctx, &p->FragProg);

View file

@ -36,6 +36,8 @@
#include "texmem.h"
#include "drivers/common/driverfuncs.h"
#include "intel_screen.h"
#include "intel_batchbuffer.h"
@ -961,15 +963,8 @@ void i915InitState( i915ContextPtr i915 )
i915_init_packets( i915 );
intelInitState( ctx );
_mesa_init_driver_state(ctx);
memcpy( &i915->initial, &i915->state, sizeof(i915->state) );
i915->current = &i915->state;
}

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);
@ -495,12 +491,19 @@ static void i915SetTexImages( i915ContextPtr i915,
abort();
}
if (i915->intel.intelScreen->deviceID == PCI_CHIP_I945_G ||
i915->intel.intelScreen->deviceID == PCI_CHIP_I945_GM)
i945LayoutTextureImages( i915, tObj );
else
i915LayoutTextureImages( i915, tObj );
switch (i915->intel.intelScreen->deviceID) {
case PCI_CHIP_I945_G:
case PCI_CHIP_I945_GM:
case PCI_CHIP_I945_GME:
case PCI_CHIP_G33_G:
case PCI_CHIP_Q33_G:
case PCI_CHIP_Q35_G:
i945LayoutTextureImages( i915, tObj );
break;
default:
i915LayoutTextureImages( i915, tObj );
break;
}
t->Setup[I915_TEXREG_MS3] =
(((tObj->Image[0][t->intel.base.firstLevel]->Height - 1) << MS3_HEIGHT_SHIFT) |

View file

@ -123,6 +123,14 @@ const GLubyte *intelGetString( GLcontext *ctx, GLenum name )
chipset = "Intel(R) 945G"; break;
case PCI_CHIP_I945_GM:
chipset = "Intel(R) 945GM"; break;
case PCI_CHIP_I945_GME:
chipset = "Intel(R) 945GME"; break;
case PCI_CHIP_G33_G:
chipset = "Intel(R) G33"; break;
case PCI_CHIP_Q35_G:
chipset = "Intel(R) Q35"; break;
case PCI_CHIP_Q33_G:
chipset = "Intel(R) Q33"; break;
default:
chipset = "Unknown Intel Chipset"; break;
}
@ -766,98 +774,3 @@ void intelCopySubBuffer( __DRIdrawablePrivate *dPriv,
fprintf(stderr, "%s: drawable has no context!\n", __FUNCTION__);
}
}
void intelInitState( GLcontext *ctx )
{
/* Mesa should do this for us:
*/
ctx->Driver.AlphaFunc( ctx,
ctx->Color.AlphaFunc,
ctx->Color.AlphaRef);
ctx->Driver.BlendColor( ctx,
ctx->Color.BlendColor );
ctx->Driver.BlendEquationSeparate( ctx,
ctx->Color.BlendEquationRGB,
ctx->Color.BlendEquationA);
ctx->Driver.BlendFuncSeparate( ctx,
ctx->Color.BlendSrcRGB,
ctx->Color.BlendDstRGB,
ctx->Color.BlendSrcA,
ctx->Color.BlendDstA);
ctx->Driver.ColorMask( ctx,
ctx->Color.ColorMask[RCOMP],
ctx->Color.ColorMask[GCOMP],
ctx->Color.ColorMask[BCOMP],
ctx->Color.ColorMask[ACOMP]);
ctx->Driver.CullFace( ctx, ctx->Polygon.CullFaceMode );
ctx->Driver.DepthFunc( ctx, ctx->Depth.Func );
ctx->Driver.DepthMask( ctx, ctx->Depth.Mask );
ctx->Driver.Enable( ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled );
ctx->Driver.Enable( ctx, GL_BLEND, ctx->Color.BlendEnabled );
ctx->Driver.Enable( ctx, GL_COLOR_LOGIC_OP, ctx->Color.ColorLogicOpEnabled );
ctx->Driver.Enable( ctx, GL_COLOR_SUM, ctx->Fog.ColorSumEnabled );
ctx->Driver.Enable( ctx, GL_CULL_FACE, ctx->Polygon.CullFlag );
ctx->Driver.Enable( ctx, GL_DEPTH_TEST, ctx->Depth.Test );
ctx->Driver.Enable( ctx, GL_DITHER, ctx->Color.DitherFlag );
ctx->Driver.Enable( ctx, GL_FOG, ctx->Fog.Enabled );
ctx->Driver.Enable( ctx, GL_LIGHTING, ctx->Light.Enabled );
ctx->Driver.Enable( ctx, GL_LINE_SMOOTH, ctx->Line.SmoothFlag );
ctx->Driver.Enable( ctx, GL_POLYGON_STIPPLE, ctx->Polygon.StippleFlag );
ctx->Driver.Enable( ctx, GL_SCISSOR_TEST, ctx->Scissor.Enabled );
ctx->Driver.Enable( ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled );
ctx->Driver.Enable( ctx, GL_TEXTURE_1D, GL_FALSE );
ctx->Driver.Enable( ctx, GL_TEXTURE_2D, GL_FALSE );
ctx->Driver.Enable( ctx, GL_TEXTURE_RECTANGLE_NV, GL_FALSE );
ctx->Driver.Enable( ctx, GL_TEXTURE_3D, GL_FALSE );
ctx->Driver.Enable( ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE );
ctx->Driver.Fogfv( ctx, GL_FOG_COLOR, ctx->Fog.Color );
ctx->Driver.Fogfv( ctx, GL_FOG_MODE, 0 );
ctx->Driver.Fogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density );
ctx->Driver.Fogfv( ctx, GL_FOG_START, &ctx->Fog.Start );
ctx->Driver.Fogfv( ctx, GL_FOG_END, &ctx->Fog.End );
ctx->Driver.FrontFace( ctx, ctx->Polygon.FrontFace );
{
GLfloat f = (GLfloat)ctx->Light.Model.ColorControl;
ctx->Driver.LightModelfv( ctx, GL_LIGHT_MODEL_COLOR_CONTROL, &f );
}
ctx->Driver.LineWidth( ctx, ctx->Line.Width );
ctx->Driver.LogicOpcode( ctx, ctx->Color.LogicOp );
ctx->Driver.PointSize( ctx, ctx->Point.Size );
ctx->Driver.PolygonStipple( ctx, (const GLubyte *)ctx->PolygonStipple );
ctx->Driver.Scissor( ctx, ctx->Scissor.X, ctx->Scissor.Y,
ctx->Scissor.Width, ctx->Scissor.Height );
ctx->Driver.ShadeModel( ctx, ctx->Light.ShadeModel );
ctx->Driver.StencilFuncSeparate( ctx, GL_FRONT,
ctx->Stencil.Function[0],
ctx->Stencil.Ref[0],
ctx->Stencil.ValueMask[0] );
ctx->Driver.StencilFuncSeparate( ctx, GL_BACK,
ctx->Stencil.Function[1],
ctx->Stencil.Ref[1],
ctx->Stencil.ValueMask[1] );
ctx->Driver.StencilMaskSeparate( ctx, GL_FRONT, ctx->Stencil.WriteMask[0] );
ctx->Driver.StencilMaskSeparate( ctx, GL_BACK, ctx->Stencil.WriteMask[1] );
ctx->Driver.StencilOpSeparate( ctx, GL_FRONT,
ctx->Stencil.FailFunc[0],
ctx->Stencil.ZFailFunc[0],
ctx->Stencil.ZPassFunc[0]);
ctx->Driver.StencilOpSeparate( ctx, GL_BACK,
ctx->Stencil.FailFunc[1],
ctx->Stencil.ZFailFunc[1],
ctx->Stencil.ZPassFunc[1]);
ctx->Driver.DrawBuffer( ctx, ctx->Color.DrawBuffer[0] );
}

View file

@ -454,6 +454,10 @@ extern int INTEL_DEBUG;
#define PCI_CHIP_I915_GM 0x2592
#define PCI_CHIP_I945_G 0x2772
#define PCI_CHIP_I945_GM 0x27A2
#define PCI_CHIP_I945_GME 0x27AE
#define PCI_CHIP_G33_G 0x29C2
#define PCI_CHIP_Q35_G 0x29B2
#define PCI_CHIP_Q33_G 0x29D2
/* ================================================================
@ -473,7 +477,6 @@ extern void intelSetBackClipRects(intelContextPtr intel);
extern void intelSetFrontClipRects(intelContextPtr intel);
extern void intelWindowMoved( intelContextPtr intel );
extern void intelInitState( GLcontext *ctx );
extern const GLubyte *intelGetString( GLcontext *ctx, GLenum name );

View file

@ -514,6 +514,10 @@ static GLboolean intelCreateContext( const __GLcontextModes *mesaVis,
case PCI_CHIP_I915_GM:
case PCI_CHIP_I945_G:
case PCI_CHIP_I945_GM:
case PCI_CHIP_I945_GME:
case PCI_CHIP_G33_G:
case PCI_CHIP_Q35_G:
case PCI_CHIP_Q33_G:
return i915CreateContext( mesaVis, driContextPriv,
sharedContextPrivate );

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,36 +667,21 @@ 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:
*/
else if (intel->intelScreen->deviceID == PCI_CHIP_I945_G ||
intel->intelScreen->deviceID == PCI_CHIP_I945_GM) {
intel->intelScreen->deviceID == PCI_CHIP_I945_GM ||
intel->intelScreen->deviceID == PCI_CHIP_I945_GME ||
intel->intelScreen->deviceID == PCI_CHIP_G33_G ||
intel->intelScreen->deviceID == PCI_CHIP_Q33_G ||
intel->intelScreen->deviceID == PCI_CHIP_Q35_G) {
GLuint row_len = image->Width * image->TexFormat->TexelBytes;
GLubyte *dst = (GLubyte *)(t->BufAddr + offset);
GLubyte *src = (GLubyte *)image->Data;

View file

@ -575,6 +575,7 @@
#define MT_16BIT_DIB_RGB565_8888 (7<<3)
#define MT_32BIT_ARGB8888 (0<<3) /* SURFACE_32BIT */
#define MT_32BIT_ABGR8888 (1<<3)
#define MT_32BIT_XRGB8888 (2<<3) /* XXX: Guess from i915_reg.h */
#define MT_32BIT_BUMP_XLDVDU_8888 (6<<3)
#define MT_32BIT_DIB_8888 (7<<3)
#define MT_411_YUV411 (0<<3) /* SURFACE_411 */

View file

@ -34,6 +34,8 @@
#include "texmem.h"
#include "drivers/common/driverfuncs.h"
#include "intel_screen.h"
#include "intel_batchbuffer.h"
#include "intel_fbo.h"
@ -1101,7 +1103,7 @@ i830InitState(struct i830_context *i830)
i830_init_packets(i830);
intelInitState(ctx);
_mesa_init_driver_state(ctx);
memcpy(&i830->initial, &i830->state, sizeof(i830->state));

View file

@ -117,7 +117,7 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
struct intel_texture_object *intelObj = intel_texture_object(tObj);
struct gl_texture_image *firstImage;
GLuint *state = i830->state.Tex[unit];
GLuint *state = i830->state.Tex[unit], format, pitch;
memset(state, 0, sizeof(state));
@ -128,7 +128,7 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
i830->state.tex_buffer[unit] = NULL;
}
if (!intel_finalize_mipmap_tree(intel, unit))
if (!intelObj->imageOverride && !intel_finalize_mipmap_tree(intel, unit))
return GL_FALSE;
/* Get first image here, since intelObj->firstLevel will get set in
@ -136,11 +136,34 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
*/
firstImage = tObj->Image[0][intelObj->firstLevel];
i830->state.tex_buffer[unit] = driBOReference(intelObj->mt->region->buffer);
i830->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt, 0,
intelObj->
firstLevel);
if (intelObj->imageOverride) {
i830->state.tex_buffer[unit] = NULL;
i830->state.tex_offset[unit] = intelObj->textureOffset;
switch (intelObj->depthOverride) {
case 32:
format = MAPSURF_32BIT | MT_32BIT_ARGB8888;
break;
case 24:
default:
format = MAPSURF_32BIT | MT_32BIT_XRGB8888;
break;
case 16:
format = MAPSURF_16BIT | MT_16BIT_RGB565;
break;
}
pitch = intelObj->pitchOverride;
} else {
i830->state.tex_buffer[unit] = driBOReference(intelObj->mt->region->
buffer);
i830->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt,
0, intelObj->
firstLevel);
format = translate_texture_format(firstImage->TexFormat->MesaFormat);
pitch = intelObj->mt->pitch * intelObj->mt->cpp;
}
state[I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
(LOAD_TEXTURE_MAP0 << unit) | 4);
@ -151,12 +174,10 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
state[I830_TEXREG_TM0S1] =
(((firstImage->Height - 1) << TM0S1_HEIGHT_SHIFT) |
((firstImage->Width - 1) << TM0S1_WIDTH_SHIFT) |
translate_texture_format(firstImage->TexFormat->MesaFormat));
((firstImage->Width - 1) << TM0S1_WIDTH_SHIFT) | format);
state[I830_TEXREG_TM0S2] =
(((((intelObj->mt->pitch * intelObj->mt->cpp) / 4) -
1) << TM0S2_PITCH_SHIFT) | TM0S2_CUBE_FACE_ENA_MASK);
((((pitch / 4) - 1) << TM0S2_PITCH_SHIFT) | TM0S2_CUBE_FACE_ENA_MASK);
{
if (tObj->Target == GL_TEXTURE_CUBE_MAP)

View file

@ -849,11 +849,6 @@ i915BindProgram(GLcontext * ctx, GLenum target, struct gl_program *prog)
assert(p->on_hardware == 0);
assert(p->params_uptodate == 0);
/* Hack: make sure fog is correctly enabled according to this
* fragment program's fog options.
*/
ctx->Driver.Enable(ctx, GL_FRAGMENT_PROGRAM_ARB,
ctx->FragmentProgram.Enabled);
}
}
@ -926,9 +921,6 @@ i915ProgramStringNotify(GLcontext * ctx,
/* Hack: make sure fog is correctly enabled according to this
* fragment program's fog options.
*/
ctx->Driver.Enable(ctx, GL_FRAGMENT_PROGRAM_ARB,
ctx->FragmentProgram.Enabled);
if (p->FragProg.FogOption) {
/* add extra instructions to do fog, then turn off FogOption field */
_mesa_append_fog_code(ctx, &p->FragProg);

View file

@ -36,6 +36,8 @@
#include "texmem.h"
#include "drivers/common/driverfuncs.h"
#include "intel_fbo.h"
#include "intel_screen.h"
#include "intel_batchbuffer.h"
@ -1005,7 +1007,7 @@ i915InitState(struct i915_context *i915)
i915_init_packets(i915);
intelInitState(ctx);
_mesa_init_driver_state(ctx);
memcpy(&i915->initial, &i915->state, sizeof(i915->state));
i915->current = &i915->state;

View file

@ -113,7 +113,7 @@ i915_miptree_layout(struct intel_mipmap_tree * mt)
*/
for (level = mt->first_level; level <= MAX2(8, mt->last_level);
level++) {
intel_miptree_set_level_info(mt, level, 1, 0, mt->total_height,
intel_miptree_set_level_info(mt, level, depth, 0, mt->total_height,
width, height, depth);
@ -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

@ -122,7 +122,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
struct intel_texture_object *intelObj = intel_texture_object(tObj);
struct gl_texture_image *firstImage;
GLuint *state = i915->state.Tex[unit];
GLuint *state = i915->state.Tex[unit], format, pitch;
memset(state, 0, sizeof(state));
@ -133,7 +133,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
i915->state.tex_buffer[unit] = NULL;
}
if (!intel_finalize_mipmap_tree(intel, unit))
if (!intelObj->imageOverride && !intel_finalize_mipmap_tree(intel, unit))
return GL_FALSE;
/* Get first image here, since intelObj->firstLevel will get set in
@ -141,24 +141,45 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
*/
firstImage = tObj->Image[0][intelObj->firstLevel];
i915->state.tex_buffer[unit] = driBOReference(intelObj->mt->region->buffer);
i915->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt, 0,
intelObj->
firstLevel);
if (intelObj->imageOverride) {
i915->state.tex_buffer[unit] = NULL;
i915->state.tex_offset[unit] = intelObj->textureOffset;
switch (intelObj->depthOverride) {
case 32:
format = MAPSURF_32BIT | MT_32BIT_ARGB8888;
break;
case 24:
default:
format = MAPSURF_32BIT | MT_32BIT_XRGB8888;
break;
case 16:
format = MAPSURF_16BIT | MT_16BIT_RGB565;
break;
}
pitch = intelObj->pitchOverride;
} else {
i915->state.tex_buffer[unit] = driBOReference(intelObj->mt->region->
buffer);
i915->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt,
0, intelObj->
firstLevel);
format = translate_texture_format(firstImage->TexFormat->MesaFormat);
pitch = intelObj->mt->pitch * intelObj->mt->cpp;
}
state[I915_TEXREG_MS3] =
(((firstImage->Height - 1) << MS3_HEIGHT_SHIFT) |
((firstImage->Width - 1) << MS3_WIDTH_SHIFT) |
translate_texture_format(firstImage->TexFormat->MesaFormat) |
((firstImage->Width - 1) << MS3_WIDTH_SHIFT) | format |
MS3_USE_FENCE_REGS);
state[I915_TEXREG_MS4] =
(((((intelObj->mt->pitch * intelObj->mt->cpp) / 4) -
1) << MS4_PITCH_SHIFT) | MS4_CUBE_FACE_ENA_MASK |
((((intelObj->lastLevel -
intelObj->firstLevel) *
4)) << MS4_MAX_LOD_SHIFT) | ((firstImage->Depth -
1) << MS4_VOLUME_DEPTH_SHIFT));
((((pitch / 4) - 1) << MS4_PITCH_SHIFT) | MS4_CUBE_FACE_ENA_MASK |
((((intelObj->lastLevel - intelObj->firstLevel) * 4)) <<
MS4_MAX_LOD_SHIFT) | ((firstImage->Depth - 1) <<
MS4_VOLUME_DEPTH_SHIFT));
{

View file

@ -381,11 +381,13 @@ i915_emit_state(struct intel_context *intel)
DRM_BO_MASK_MEM | DRM_BO_FLAG_READ,
state->tex_offset[i]);
}
else {
else if (state == &i915->meta) {
assert(i == 0);
assert(state == &i915->meta);
OUT_BATCH(0);
}
else {
OUT_BATCH(state->tex_offset[i]);
}
OUT_BATCH(state->Tex[i][I915_TEXREG_MS3]);
OUT_BATCH(state->Tex[i][I915_TEXREG_MS4]);

View file

@ -130,6 +130,18 @@ intelGetString(GLcontext * ctx, GLenum name)
case PCI_CHIP_I945_GM:
chipset = "Intel(R) 945GM";
break;
case PCI_CHIP_I945_GME:
chipset = "Intel(R) 945GME";
break;
case PCI_CHIP_G33_G:
chipset = "Intel(R) G33";
break;
case PCI_CHIP_Q35_G:
chipset = "Intel(R) Q35";
break;
case PCI_CHIP_Q33_G:
chipset = "Intel(R) Q33";
break;
default:
chipset = "Unknown Intel Chipset";
break;

View file

@ -92,6 +92,10 @@ struct intel_texture_object
* regions will be copied to this region and the old storage freed.
*/
struct intel_mipmap_tree *mt;
GLboolean imageOverride;
GLint depthOverride;
GLuint pitchOverride;
};
@ -381,6 +385,10 @@ extern int INTEL_DEBUG;
#define PCI_CHIP_I915_GM 0x2592
#define PCI_CHIP_I945_G 0x2772
#define PCI_CHIP_I945_GM 0x27A2
#define PCI_CHIP_I945_GME 0x27AE
#define PCI_CHIP_G33_G 0x29C2
#define PCI_CHIP_Q35_G 0x29B2
#define PCI_CHIP_Q33_G 0x29D2
/* ================================================================
@ -395,7 +403,6 @@ extern GLboolean intelInitContext(struct intel_context *intel,
extern void intelGetLock(struct intel_context *intel, GLuint flags);
extern void intelInitState(GLcontext * ctx);
extern void intelFinish(GLcontext * ctx);
extern void intelFlush(GLcontext * ctx);

View file

@ -79,6 +79,10 @@ intel_miptree_create(struct intel_context *intel,
switch (intel->intelScreen->deviceID) {
case PCI_CHIP_I945_G:
case PCI_CHIP_I945_GM:
case PCI_CHIP_I945_GME:
case PCI_CHIP_G33_G:
case PCI_CHIP_Q33_G:
case PCI_CHIP_Q35_G:
ok = i945_miptree_layout(mt);
break;
case PCI_CHIP_I915_G:

View file

@ -752,6 +752,10 @@ intelCreateContext(const __GLcontextModes * mesaVis,
case PCI_CHIP_I915_GM:
case PCI_CHIP_I945_G:
case PCI_CHIP_I945_GM:
case PCI_CHIP_I945_GME:
case PCI_CHIP_G33_G:
case PCI_CHIP_Q35_G:
case PCI_CHIP_Q33_G:
return i915CreateContext(mesaVis, driContextPriv, sharedContextPrivate);
default:
@ -776,7 +780,8 @@ static const struct __DriverAPIRec intelAPI = {
.WaitForMSC = driWaitForMSC32,
.WaitForSBC = NULL,
.SwapBuffersMSC = NULL,
.CopySubBuffer = intelCopySubBuffer
.CopySubBuffer = intelCopySubBuffer,
.setTexOffset = intelSetTexOffset,
};

View file

@ -267,97 +267,3 @@ intelInitStateFuncs(struct dd_function_table *functions)
functions->DepthRange = intelDepthRange;
functions->ClearColor = intelClearColor;
}
void
intelInitState(GLcontext * ctx)
{
/* Mesa should do this for us:
*/
ctx->Driver.AlphaFunc(ctx, ctx->Color.AlphaFunc, ctx->Color.AlphaRef);
ctx->Driver.BlendColor(ctx, ctx->Color.BlendColor);
ctx->Driver.BlendEquationSeparate(ctx,
ctx->Color.BlendEquationRGB,
ctx->Color.BlendEquationA);
ctx->Driver.BlendFuncSeparate(ctx,
ctx->Color.BlendSrcRGB,
ctx->Color.BlendDstRGB,
ctx->Color.BlendSrcA, ctx->Color.BlendDstA);
ctx->Driver.ColorMask(ctx,
ctx->Color.ColorMask[RCOMP],
ctx->Color.ColorMask[GCOMP],
ctx->Color.ColorMask[BCOMP],
ctx->Color.ColorMask[ACOMP]);
ctx->Driver.CullFace(ctx, ctx->Polygon.CullFaceMode);
ctx->Driver.DepthFunc(ctx, ctx->Depth.Func);
ctx->Driver.DepthMask(ctx, ctx->Depth.Mask);
ctx->Driver.Enable(ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled);
ctx->Driver.Enable(ctx, GL_BLEND, ctx->Color.BlendEnabled);
ctx->Driver.Enable(ctx, GL_COLOR_LOGIC_OP, ctx->Color.ColorLogicOpEnabled);
ctx->Driver.Enable(ctx, GL_COLOR_SUM, ctx->Fog.ColorSumEnabled);
ctx->Driver.Enable(ctx, GL_CULL_FACE, ctx->Polygon.CullFlag);
ctx->Driver.Enable(ctx, GL_DEPTH_TEST, ctx->Depth.Test);
ctx->Driver.Enable(ctx, GL_DITHER, ctx->Color.DitherFlag);
ctx->Driver.Enable(ctx, GL_FOG, ctx->Fog.Enabled);
ctx->Driver.Enable(ctx, GL_LIGHTING, ctx->Light.Enabled);
ctx->Driver.Enable(ctx, GL_LINE_SMOOTH, ctx->Line.SmoothFlag);
ctx->Driver.Enable(ctx, GL_POLYGON_STIPPLE, ctx->Polygon.StippleFlag);
ctx->Driver.Enable(ctx, GL_SCISSOR_TEST, ctx->Scissor.Enabled);
ctx->Driver.Enable(ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled);
ctx->Driver.Enable(ctx, GL_TEXTURE_1D, GL_FALSE);
ctx->Driver.Enable(ctx, GL_TEXTURE_2D, GL_FALSE);
ctx->Driver.Enable(ctx, GL_TEXTURE_RECTANGLE_NV, GL_FALSE);
ctx->Driver.Enable(ctx, GL_TEXTURE_3D, GL_FALSE);
ctx->Driver.Enable(ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE);
ctx->Driver.Fogfv(ctx, GL_FOG_COLOR, ctx->Fog.Color);
ctx->Driver.Fogfv(ctx, GL_FOG_MODE, 0);
ctx->Driver.Fogfv(ctx, GL_FOG_DENSITY, &ctx->Fog.Density);
ctx->Driver.Fogfv(ctx, GL_FOG_START, &ctx->Fog.Start);
ctx->Driver.Fogfv(ctx, GL_FOG_END, &ctx->Fog.End);
ctx->Driver.FrontFace(ctx, ctx->Polygon.FrontFace);
{
GLfloat f = (GLfloat) ctx->Light.Model.ColorControl;
ctx->Driver.LightModelfv(ctx, GL_LIGHT_MODEL_COLOR_CONTROL, &f);
}
ctx->Driver.LineWidth(ctx, ctx->Line.Width);
ctx->Driver.LogicOpcode(ctx, ctx->Color.LogicOp);
ctx->Driver.PointSize(ctx, ctx->Point.Size);
ctx->Driver.PolygonStipple(ctx, (const GLubyte *) ctx->PolygonStipple);
ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
ctx->Scissor.Width, ctx->Scissor.Height);
ctx->Driver.ShadeModel(ctx, ctx->Light.ShadeModel);
ctx->Driver.StencilFuncSeparate(ctx, GL_FRONT,
ctx->Stencil.Function[0],
ctx->Stencil.Ref[0],
ctx->Stencil.ValueMask[0]);
ctx->Driver.StencilFuncSeparate(ctx, GL_BACK,
ctx->Stencil.Function[1],
ctx->Stencil.Ref[1],
ctx->Stencil.ValueMask[1]);
ctx->Driver.StencilMaskSeparate(ctx, GL_FRONT, ctx->Stencil.WriteMask[0]);
ctx->Driver.StencilMaskSeparate(ctx, GL_BACK, ctx->Stencil.WriteMask[1]);
ctx->Driver.StencilOpSeparate(ctx, GL_FRONT,
ctx->Stencil.FailFunc[0],
ctx->Stencil.ZFailFunc[0],
ctx->Stencil.ZPassFunc[0]);
ctx->Driver.StencilOpSeparate(ctx, GL_BACK,
ctx->Stencil.FailFunc[1],
ctx->Stencil.ZFailFunc[1],
ctx->Stencil.ZPassFunc[1]);
/* XXX this isn't really needed */
ctx->Driver.DrawBuffer(ctx, ctx->Color.DrawBuffer[0]);
}

View file

@ -135,6 +135,9 @@ void intelGetCompressedTexImage(GLcontext *ctx, GLenum target, GLint level,
const struct gl_texture_object *texObj,
const struct gl_texture_image *texImage);
void intelSetTexOffset(__DRIcontext *pDRICtx, GLint texname,
unsigned long long offset, GLint depth, GLuint pitch);
GLuint intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit);
void intel_tex_map_images(struct intel_context *intel,

View file

@ -385,7 +385,6 @@ intelTexImage(GLcontext * ctx,
}
}
assert(!intelImage->mt);
if (intelObj->mt &&
@ -667,3 +666,26 @@ intelGetCompressedTexImage(GLcontext *ctx, GLenum target, GLint level,
texObj, texImage, 1);
}
void
intelSetTexOffset(__DRIcontext *pDRICtx, GLint texname,
unsigned long long offset, GLint depth, GLuint pitch)
{
struct intel_context *intel = (struct intel_context*)
((__DRIcontextPrivate*)pDRICtx->private)->driverPrivate;
struct gl_texture_object *tObj = _mesa_lookup_texture(&intel->ctx, texname);
struct intel_texture_object *intelObj = intel_texture_object(tObj);
if (!intelObj)
return;
if (intelObj->mt)
intel_miptree_release(intel, &intelObj->mt);
intelObj->imageOverride = GL_TRUE;
intelObj->depthOverride = depth;
intelObj->pitchOverride = pitch;
if (offset)
intelObj->textureOffset = offset;
}

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

@ -47,6 +47,7 @@
#include "tnl/tnl.h"
#include "vbo/vbo_context.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"

View file

@ -1154,7 +1154,9 @@ static void build_fog( struct tnl_program *p )
{
struct ureg fog = register_output(p, VERT_RESULT_FOGC);
struct ureg input;
GLuint useabs = p->state->fog_source_is_depth && p->state->fog_option &&
(p->state->fog_option != FOG_EXP2);
if (p->state->fog_source_is_depth) {
input = swizzle1(get_eye_position(p), Z);
}
@ -1171,26 +1173,30 @@ static void build_fog( struct tnl_program *p )
emit_op1(p, OPCODE_MOV, fog, 0, id);
if (useabs) {
emit_op1(p, OPCODE_ABS, tmp, 0, input);
}
switch (p->state->fog_option) {
case FOG_LINEAR: {
emit_op1(p, OPCODE_ABS, tmp, 0, input);
emit_op3(p, OPCODE_MAD, tmp, 0, tmp, swizzle1(params,X), swizzle1(params,Y));
emit_op3(p, OPCODE_MAD, tmp, 0, useabs ? tmp : input,
swizzle1(params,X), swizzle1(params,Y));
emit_op2(p, OPCODE_MAX, tmp, 0, tmp, swizzle1(id,X)); /* saturate */
emit_op2(p, OPCODE_MIN, fog, WRITEMASK_X, tmp, swizzle1(id,W));
break;
}
case FOG_EXP:
emit_op1(p, OPCODE_ABS, tmp, 0, input);
emit_op2(p, OPCODE_MUL, tmp, 0, tmp, swizzle1(params,Z));
emit_op2(p, OPCODE_MUL, tmp, 0, useabs ? tmp : input,
swizzle1(params,Z));
emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, ureg_negate(tmp));
break;
case FOG_EXP2:
emit_op2(p, OPCODE_MUL, tmp, 0, input, swizzle1(params,W));
emit_op2(p, OPCODE_MUL, tmp, 0, tmp, tmp);
emit_op2(p, OPCODE_MUL, tmp, 0, tmp, tmp);
emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, ureg_negate(tmp));
break;
}
release_temp(p, tmp);
}
else {
@ -1198,7 +1204,7 @@ static void build_fog( struct tnl_program *p )
*
* KW: Is it really necessary to do anything in this case?
*/
emit_op1(p, OPCODE_MOV, fog, 0, input);
emit_op1(p, useabs ? OPCODE_ABS : OPCODE_MOV, fog, 0, input);
}
}

View file

@ -106,20 +106,23 @@ static const GLubyte *intelGetString( GLcontext *ctx, GLenum name )
case GL_RENDERER:
switch (intel_context(ctx)->intelScreen->deviceID) {
case PCI_CHIP_I965_Q:
chipset = "Intel(R) 965Q"; break;
chipset = "Intel(R) 965Q";
break;
case PCI_CHIP_I965_G:
case PCI_CHIP_I965_G_1:
chipset = "Intel(R) 965G"; break;
chipset = "Intel(R) 965G";
break;
case PCI_CHIP_I946_GZ:
chipset = "Intel(R) 946GZ"; break;
chipset = "Intel(R) 946GZ";
break;
case PCI_CHIP_I965_GM:
chipset = "Intel(R) 965GM"; break;
chipset = "Intel(R) 965GM";
break;
case PCI_CHIP_I965_GME:
chipset = "Intel(R) 965GME/GLE";
break;
default:
chipset = "Unknown Intel Chipset"; break;
chipset = "Unknown Intel Chipset";
}
(void) driGetRendererString( buffer, chipset, DRIVER_VERSION, 0 );

View file

@ -385,6 +385,7 @@ extern int INTEL_DEBUG;
#define PCI_CHIP_I965_G_1 0x2982
#define PCI_CHIP_I946_GZ 0x2972
#define PCI_CHIP_I965_GM 0x2A02
#define PCI_CHIP_I965_GME 0x2A12
/* ================================================================
@ -399,7 +400,6 @@ extern GLboolean intelInitContext( struct intel_context *intel,
extern void intelGetLock(struct intel_context *intel, GLuint flags);
extern void intelInitState( GLcontext *ctx );
extern void intelFinish( GLcontext *ctx );
extern void intelFlush( GLcontext *ctx );

View file

@ -197,99 +197,3 @@ void intelInitStateFuncs( struct dd_function_table *functions )
functions->RenderMode = intelRenderMode;
functions->ClearColor = intelClearColor;
}
void intelInitState( GLcontext *ctx )
{
/* Mesa should do this for us:
*/
ctx->Driver.AlphaFunc( ctx,
ctx->Color.AlphaFunc,
ctx->Color.AlphaRef);
ctx->Driver.BlendColor( ctx,
ctx->Color.BlendColor );
ctx->Driver.BlendEquationSeparate( ctx,
ctx->Color.BlendEquationRGB,
ctx->Color.BlendEquationA);
ctx->Driver.BlendFuncSeparate( ctx,
ctx->Color.BlendSrcRGB,
ctx->Color.BlendDstRGB,
ctx->Color.BlendSrcA,
ctx->Color.BlendDstA);
ctx->Driver.ColorMask( ctx,
ctx->Color.ColorMask[RCOMP],
ctx->Color.ColorMask[GCOMP],
ctx->Color.ColorMask[BCOMP],
ctx->Color.ColorMask[ACOMP]);
ctx->Driver.CullFace( ctx, ctx->Polygon.CullFaceMode );
ctx->Driver.DepthFunc( ctx, ctx->Depth.Func );
ctx->Driver.DepthMask( ctx, ctx->Depth.Mask );
ctx->Driver.Enable( ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled );
ctx->Driver.Enable( ctx, GL_BLEND, ctx->Color.BlendEnabled );
ctx->Driver.Enable( ctx, GL_COLOR_LOGIC_OP, ctx->Color.ColorLogicOpEnabled );
ctx->Driver.Enable( ctx, GL_COLOR_SUM, ctx->Fog.ColorSumEnabled );
ctx->Driver.Enable( ctx, GL_CULL_FACE, ctx->Polygon.CullFlag );
ctx->Driver.Enable( ctx, GL_DEPTH_TEST, ctx->Depth.Test );
ctx->Driver.Enable( ctx, GL_DITHER, ctx->Color.DitherFlag );
ctx->Driver.Enable( ctx, GL_FOG, ctx->Fog.Enabled );
ctx->Driver.Enable( ctx, GL_LIGHTING, ctx->Light.Enabled );
ctx->Driver.Enable( ctx, GL_LINE_SMOOTH, ctx->Line.SmoothFlag );
ctx->Driver.Enable( ctx, GL_POLYGON_STIPPLE, ctx->Polygon.StippleFlag );
ctx->Driver.Enable( ctx, GL_SCISSOR_TEST, ctx->Scissor.Enabled );
ctx->Driver.Enable( ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled );
ctx->Driver.Enable( ctx, GL_TEXTURE_1D, GL_FALSE );
ctx->Driver.Enable( ctx, GL_TEXTURE_2D, GL_FALSE );
ctx->Driver.Enable( ctx, GL_TEXTURE_RECTANGLE_NV, GL_FALSE );
ctx->Driver.Enable( ctx, GL_TEXTURE_3D, GL_FALSE );
ctx->Driver.Enable( ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE );
ctx->Driver.Fogfv( ctx, GL_FOG_COLOR, ctx->Fog.Color );
ctx->Driver.Fogfv( ctx, GL_FOG_MODE, 0 );
ctx->Driver.Fogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density );
ctx->Driver.Fogfv( ctx, GL_FOG_START, &ctx->Fog.Start );
ctx->Driver.Fogfv( ctx, GL_FOG_END, &ctx->Fog.End );
ctx->Driver.FrontFace( ctx, ctx->Polygon.FrontFace );
{
GLfloat f = (GLfloat)ctx->Light.Model.ColorControl;
ctx->Driver.LightModelfv( ctx, GL_LIGHT_MODEL_COLOR_CONTROL, &f );
}
ctx->Driver.LineWidth( ctx, ctx->Line.Width );
ctx->Driver.LogicOpcode( ctx, ctx->Color.LogicOp );
ctx->Driver.PointSize( ctx, ctx->Point.Size );
ctx->Driver.PolygonStipple( ctx, (const GLubyte *)ctx->PolygonStipple );
ctx->Driver.Scissor( ctx, ctx->Scissor.X, ctx->Scissor.Y,
ctx->Scissor.Width, ctx->Scissor.Height );
ctx->Driver.ShadeModel( ctx, ctx->Light.ShadeModel );
ctx->Driver.StencilFuncSeparate( ctx, GL_FRONT,
ctx->Stencil.Function[0],
ctx->Stencil.Ref[0],
ctx->Stencil.ValueMask[0] );
ctx->Driver.StencilFuncSeparate( ctx, GL_BACK,
ctx->Stencil.Function[1],
ctx->Stencil.Ref[1],
ctx->Stencil.ValueMask[1] );
ctx->Driver.StencilMaskSeparate( ctx, GL_FRONT, ctx->Stencil.WriteMask[0] );
ctx->Driver.StencilMaskSeparate( ctx, GL_BACK, ctx->Stencil.WriteMask[1] );
ctx->Driver.StencilOpSeparate( ctx, GL_FRONT,
ctx->Stencil.FailFunc[0],
ctx->Stencil.ZFailFunc[0],
ctx->Stencil.ZPassFunc[0]);
ctx->Driver.StencilOpSeparate( ctx, GL_BACK,
ctx->Stencil.FailFunc[1],
ctx->Stencil.ZFailFunc[1],
ctx->Stencil.ZPassFunc[1]);
ctx->Driver.DrawBuffer( ctx, ctx->Color.DrawBuffer[0] );
}

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

@ -44,7 +44,7 @@ void TAG(translate_vertex)(GLcontext *ctx,
UNVIEWPORT_VARS;
CARD32 *p = (CARD32 *)src + 10 - mmesa->vertex_size;
dst->win[3] = 1.0;
dst->attrib[FRAG_ATTRIB_WPOS][3] = 1.0;
switch ( format ) {
case TEX1_VERTEX_FORMAT:
@ -75,17 +75,17 @@ void TAG(translate_vertex)(GLcontext *ctx,
dst->attrib[FRAG_ATTRIB_TEX0][1] = LE32_IN_FLOAT( p++ );
#endif
dst->attrib[FRAG_ATTRIB_TEX0][3] = 1.0;
dst->win[3] = LE32_IN_FLOAT( p++ );
dst->attrib[FRAG_ATTRIB_WPOS][3] = LE32_IN_FLOAT( p++ );
case NOTEX_VERTEX_FORMAT:
dst->specular[2] = ((GLubyte *)p)[0];
dst->specular[1] = ((GLubyte *)p)[1];
dst->specular[0] = ((GLubyte *)p)[2];
dst->attrib[FRAG_ATTRIB_FOGC][0] = ((GLubyte *)p)[3];
dst->attrib[FRAG_ATTRIB_COL1][2] = UBYTE_TO_FLOAT(((GLubyte *)p)[0]);
dst->attrib[FRAG_ATTRIB_COL1][1] = UBYTE_TO_FLOAT(((GLubyte *)p)[1]);
dst->attrib[FRAG_ATTRIB_COL1][0] = UBYTE_TO_FLOAT(((GLubyte *)p)[2]);
dst->attrib[FRAG_ATTRIB_FOGC][0] = ((GLubyte *)p)[3]; /*XXX int->float?*/
p++;
case TINY_VERTEX_FORMAT:
dst->win[2] = UNVIEWPORT_Z( LE32_IN( p++ ) );
dst->attrib[FRAG_ATTRIB_WPOS][2] = UNVIEWPORT_Z( LE32_IN( p++ ) );
dst->color[2] = ((GLubyte *)p)[0];
dst->color[1] = ((GLubyte *)p)[1];
@ -96,8 +96,8 @@ void TAG(translate_vertex)(GLcontext *ctx,
{
GLuint xy = LE32_IN( p );
dst->win[0] = UNVIEWPORT_X( (GLfloat)(GLshort)( xy >> 16 ) );
dst->win[1] = UNVIEWPORT_Y( (GLfloat)(GLshort)( xy & 0xffff ) );
dst->attrib[FRAG_ATTRIB_WPOS][0] = UNVIEWPORT_X( (GLfloat)(GLshort)( xy >> 16 ) );
dst->attrib[FRAG_ATTRIB_WPOS][1] = UNVIEWPORT_Y( (GLfloat)(GLshort)( xy & 0xffff ) );
}
}

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_cmdbuf.c,v 1.1 2002/10/30 12:51:51 alanh Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_context.c,v 1.3 2003/05/06 23:52:08 daenzer Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
@ -679,7 +678,6 @@ r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
newCtx->dri.drawable = driDrawPriv;
r200SetCliprects(newCtx);
r200UpdateWindow( newCtx->glCtx );
r200UpdateViewportOffset( newCtx->glCtx );
}

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_context.h,v 1.2 2002/12/16 16:18:54 dawes Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_ioctl.c,v 1.4 2002/12/17 00:32:56 dawes Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_ioctl.h,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_lock.c,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_lock.h,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_maos.h,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_maos_arrays.c,v 1.3 2003/02/23 23:59:01 dawes Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_pixel.c,v 1.2 2002/12/16 16:18:54 dawes Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_pixel.h,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_reg.h,v 1.2 2002/12/16 16:18:54 dawes Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_sanity.c,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
/**************************************************************************
Copyright 2002 ATI Technologies Inc., Ontario, Canada, and

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_span.c,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_span.h,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.

View file

@ -1,4 +1,3 @@
/* $XFree86$ */
/**************************************************************************
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_state.h,v 1.2 2002/11/05 17:46:08 tsi Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_state_init.c,v 1.4 2003/02/22 06:21:11 dawes Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_swtcl.c,v 1.5 2003/05/06 23:52:08 daenzer Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_swtcl.h,v 1.3 2003/05/06 23:52:08 daenzer Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_tcl.c,v 1.2 2002/12/16 16:18:55 dawes Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_tcl.h,v 1.2 2002/12/16 16:18:55 dawes Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_tex.c,v 1.2 2002/11/05 17:46:08 tsi Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
@ -182,7 +181,7 @@ static void r200SetTexMaxAnisotropy( r200TexObjPtr t, GLfloat max )
{
t->pp_txfilter &= ~R200_MAX_ANISO_MASK;
if ( max == 1.0 ) {
if ( max <= 1.0 ) {
t->pp_txfilter |= R200_MAX_ANISO_1_TO_1;
} else if ( max <= 2.0 ) {
t->pp_txfilter |= R200_MAX_ANISO_2_TO_1;
@ -483,7 +482,7 @@ r200ValidateClientStorage( GLcontext *ctx, GLenum target,
{
r200ContextPtr rmesa = R200_CONTEXT(ctx);
if (0)
if ( R200_DEBUG & DEBUG_TEXTURE )
fprintf(stderr, "intformat %s format %s type %s\n",
_mesa_lookup_enum_by_nr( internalFormat ),
_mesa_lookup_enum_by_nr( format ),
@ -549,7 +548,7 @@ r200ValidateClientStorage( GLcontext *ctx, GLenum target,
format, type);
if (0)
if ( R200_DEBUG & DEBUG_TEXTURE )
fprintf(stderr, "%s: srcRowStride %d/%x\n",
__FUNCTION__, srcRowStride, srcRowStride);

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_tex.h,v 1.1 2002/10/30 12:51:53 alanh Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_texmem.c,v 1.5 2002/12/17 00:32:56 dawes Exp $ */
/**************************************************************************
Copyright (C) Tungsten Graphics 2002. All Rights Reserved.

View file

@ -1,4 +1,3 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_texstate.c,v 1.3 2003/02/15 22:18:47 dawes Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.

View file

@ -40,7 +40,7 @@ DRIVER_SOURCES = \
r300_vertprog.c \
r300_fragprog.c \
r300_shader.c \
r300_maos.c \
r300_emit.c \
$(EGL_SOURCES)
C_SOURCES = $(COMMON_SOURCES) $(DRIVER_SOURCES)

View file

@ -128,18 +128,20 @@ int r300FlushCmdBuf(r300ContextPtr r300, const char *caller)
return ret;
}
void r300PrintStateAtom(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);
fprintf(stderr, " emit %s/%d/%d\n", state->name, dwords,
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",
if (RADEON_DEBUG & DEBUG_VERBOSE) {
for (i = 0; i < dwords; i++) {
fprintf(stderr, " %s[%d]: %08x\n",
state->name, i, state->cmd[i]);
}
}
}
/**
@ -148,28 +150,14 @@ void r300PrintStateAtom(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;
int dwords;
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);
if (dwords)
r300PrintStateAtom(r300, atom);
else
fprintf(stderr,
" skip state %s\n",
atom->name);
}
}
}
/* Emit WAIT */
*dest = cmdwait(R300_WAIT_3D | R300_WAIT_3D_CLEAN);
dest++;
@ -193,13 +181,20 @@ static __inline__ void r300DoEmitState(r300ContextPtr r300, GLboolean dirty)
foreach(atom, &r300->hw.atomlist) {
if ((atom->dirty || r300->hw.all_dirty) == dirty) {
int dwords = (*atom->check) (r300, atom);
dwords = (*atom->check) (r300, atom);
if (dwords) {
if (DEBUG_CMDBUF && RADEON_DEBUG & DEBUG_STATE) {
r300PrintStateAtom(r300, atom);
}
memcpy(dest, atom->cmd, dwords * 4);
dest += dwords;
r300->cmdbuf.count_used += dwords;
atom->dirty = GL_FALSE;
} else {
if (DEBUG_CMDBUF && RADEON_DEBUG & DEBUG_STATE) {
fprintf(stderr, " skip state %s\n",
atom->name);
}
}
}
}
@ -230,14 +225,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);
@ -245,31 +240,38 @@ void r300EmitState(r300ContextPtr r300)
r300->hw.all_dirty = GL_FALSE;
}
#define CHECK( NM, COUNT ) \
static int check_##NM( r300ContextPtr r300, \
struct r300_state_atom* atom ) \
{ \
(void) atom; (void) r300; \
return (COUNT); \
}
#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)
#undef packet0_count
#undef vpu_count
#define ALLOC_STATE( ATOM, CHK, SZ, NM, IDX ) \
static int check_always(r300ContextPtr r300, struct r300_state_atom *atom)
{
return atom->cmd_size;
}
static int check_variable(r300ContextPtr r300, struct r300_state_atom *atom)
{
int cnt;
cnt = packet0_count(atom->cmd);
return cnt ? cnt + 1 : 0;
}
static int check_vpu(r300ContextPtr r300, struct r300_state_atom *atom)
{
int cnt;
cnt = vpu_count(atom->cmd);
return cnt ? (cnt * 4) + 1 : 0;
}
#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
@ -290,276 +292,195 @@ void r300InitCmdBuf(r300ContextPtr r300)
fprintf(stderr, "Using %d maximum texture units..\n", mtu);
}
/* Setup the atom linked list */
make_empty_list(&r300->hw.atomlist);
r300->hw.atomlist.name = "atom-list";
/* Initialize state atoms */
ALLOC_STATE(vpt, always, R300_VPT_CMDSIZE, "vpt", 0);
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, "vap_cntl", 0);
ALLOC_STATE(vap_cntl, always, 2, 0);
r300->hw.vap_cntl.cmd[0] = cmdpacket0(R300_VAP_CNTL, 1);
ALLOC_STATE(vte, always, 3, "vte", 0);
ALLOC_STATE(vte, always, 3, 0);
r300->hw.vte.cmd[0] = cmdpacket0(R300_SE_VTE_CNTL, 2);
ALLOC_STATE(unk2134, always, 3, "unk2134", 0);
ALLOC_STATE(unk2134, always, 3, 0);
r300->hw.unk2134.cmd[0] = cmdpacket0(0x2134, 2);
ALLOC_STATE(vap_cntl_status, always, 2, "vap_cntl_status", 0);
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, "vir/0", 0);
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, "vir/1", 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, "vic", 0);
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, "unk21DC", 0);
ALLOC_STATE(unk21DC, always, 2, 0);
r300->hw.unk21DC.cmd[0] = cmdpacket0(0x21DC, 1);
ALLOC_STATE(unk221C, always, 2, "unk221C", 0);
ALLOC_STATE(unk221C, always, 2, 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);
ALLOC_STATE(vap_clip, always, 5, 0);
r300->hw.vap_clip.cmd[0] = cmdpacket0(R300_VAP_CLIP_X_0, 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, "vof", 0);
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) {
ALLOC_STATE(pvs, always, R300_PVS_CMDSIZE, "pvs", 0);
ALLOC_STATE(pvs, always, R300_PVS_CMDSIZE, 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);
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, "gb_misc", 0);
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, "txe", 0);
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, "unk4200", 0);
ALLOC_STATE(unk4200, always, 5, 0);
r300->hw.unk4200.cmd[0] = cmdpacket0(0x4200, 4);
ALLOC_STATE(unk4214, always, 2, "unk4214", 0);
ALLOC_STATE(unk4214, always, 2, 0);
r300->hw.unk4214.cmd[0] = cmdpacket0(0x4214, 1);
ALLOC_STATE(ps, always, R300_PS_CMDSIZE, "ps", 0);
ALLOC_STATE(ps, always, R300_PS_CMDSIZE, 0);
r300->hw.ps.cmd[0] = cmdpacket0(R300_RE_POINTSIZE, 1);
ALLOC_STATE(unk4230, always, 4, "unk4230", 0);
ALLOC_STATE(unk4230, always, 4, 0);
r300->hw.unk4230.cmd[0] = cmdpacket0(0x4230, 3);
ALLOC_STATE(lcntl, always, 2, "lcntl", 0);
ALLOC_STATE(lcntl, always, 2, 0);
r300->hw.lcntl.cmd[0] = cmdpacket0(R300_RE_LINE_CNT, 1);
ALLOC_STATE(unk4260, always, 4, "unk4260", 0);
ALLOC_STATE(unk4260, always, 4, 0);
r300->hw.unk4260.cmd[0] = cmdpacket0(0x4260, 3);
ALLOC_STATE(shade, always, 5, "shade", 0);
ALLOC_STATE(shade, always, 5, 0);
r300->hw.shade.cmd[0] = cmdpacket0(R300_RE_SHADE, 4);
ALLOC_STATE(polygon_mode, always, 4, "polygon_mode", 0);
ALLOC_STATE(polygon_mode, always, 4, 0);
r300->hw.polygon_mode.cmd[0] = cmdpacket0(R300_RE_POLYGON_MODE, 3);
ALLOC_STATE(fogp, always, 3, "fogp", 0);
ALLOC_STATE(fogp, always, 3, 0);
r300->hw.fogp.cmd[0] = cmdpacket0(R300_RE_FOG_SCALE, 2);
ALLOC_STATE(zbias_cntl, always, 2, "zbias_cntl", 0);
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, "zbs", 0);
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, "occlusion_cntl", 0);
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, "cul", 0);
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, "unk42C0", 0);
ALLOC_STATE(unk42C0, always, 3, 0);
r300->hw.unk42C0.cmd[0] = cmdpacket0(0x42C0, 2);
ALLOC_STATE(rc, always, R300_RC_CMDSIZE, "rc", 0);
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, "ri", 0);
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, "rr", 0);
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, "unk43A4", 0);
ALLOC_STATE(unk43A4, always, 3, 0);
r300->hw.unk43A4.cmd[0] = cmdpacket0(0x43A4, 2);
ALLOC_STATE(unk43E8, always, 2, "unk43E8", 0);
ALLOC_STATE(unk43E8, always, 2, 0);
r300->hw.unk43E8.cmd[0] = cmdpacket0(0x43E8, 1);
ALLOC_STATE(fp, always, R300_FP_CMDSIZE, "fp", 0);
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, "fpt", 0);
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, "unk46A4", 0);
ALLOC_STATE(unk46A4, always, 6, 0);
r300->hw.unk46A4.cmd[0] = cmdpacket0(0x46A4, 5);
ALLOC_STATE(fpi[0], variable, R300_FPI_CMDSIZE, "fpi/0", 0);
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, "fpi/1", 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, "fpi/2", 2);
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, "fpi/3", 3);
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, "fogs", 0);
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, "fogc", 0);
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, "at", 0);
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, "unk4BD8", 0);
ALLOC_STATE(unk4BD8, always, 2, 0);
r300->hw.unk4BD8.cmd[0] = cmdpacket0(0x4BD8, 1);
ALLOC_STATE(fpp, variable, R300_FPP_CMDSIZE, "fpp", 0);
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, "unk4E00", 0);
ALLOC_STATE(unk4E00, always, 2, 0);
r300->hw.unk4E00.cmd[0] = cmdpacket0(0x4E00, 1);
ALLOC_STATE(bld, always, R300_BLD_CMDSIZE, "bld", 0);
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, "cmk", 0);
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, "blend_color", 0);
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, "cb", 0);
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, "unk4E50", 0);
ALLOC_STATE(unk4E50, always, 10, 0);
r300->hw.unk4E50.cmd[0] = cmdpacket0(0x4E50, 9);
ALLOC_STATE(unk4E88, always, 2, "unk4E88", 0);
ALLOC_STATE(unk4E88, always, 2, 0);
r300->hw.unk4E88.cmd[0] = cmdpacket0(0x4E88, 1);
ALLOC_STATE(unk4EA0, always, 3, "unk4EA0 R350 only", 0);
ALLOC_STATE(unk4EA0, always, 3, 0);
r300->hw.unk4EA0.cmd[0] = cmdpacket0(0x4EA0, 2);
ALLOC_STATE(zs, always, R300_ZS_CMDSIZE, "zstencil", 0);
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, "zstencil_format", 0);
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, "zb", 0);
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, "unk4F28", 0);
ALLOC_STATE(unk4F28, always, 2, 0);
r300->hw.unk4F28.cmd[0] = cmdpacket0(0x4F28, 1);
ALLOC_STATE(unk4F30, always, 3, "unk4F30", 0);
ALLOC_STATE(unk4F30, always, 3, 0);
r300->hw.unk4F30.cmd[0] = cmdpacket0(0x4F30, 2);
ALLOC_STATE(unk4F44, always, 2, "unk4F44", 0);
ALLOC_STATE(unk4F44, always, 2, 0);
r300->hw.unk4F44.cmd[0] = cmdpacket0(0x4F44, 1);
ALLOC_STATE(unk4F54, always, 2, "unk4F54", 0);
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, "vpi", 0);
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, "vpp", 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, "vps", 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, "tex_filter", 0);
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, "tex_filter_1", 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, "tex_size", 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, "tex_format", 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, "tex_pitch", 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, "tex_offset", 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, "tex_chroma_key", 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, "tex_border_color", 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);
/* 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);
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);
}
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);
r300->hw.is_dirty = GL_TRUE;
r300->hw.all_dirty = GL_TRUE;
@ -659,38 +580,3 @@ void r300EmitWait(r300ContextPtr rmesa, GLuint flags)
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

@ -46,15 +46,13 @@ 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,
static inline void r300EnsureCmdBufSpace(r300ContextPtr r300,
int dwords, const char *caller)
{
assert(dwords < r300->cmdbuf.size);
@ -70,7 +68,7 @@ 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,
static inline uint32_t *r300RawAllocCmdBuf(r300ContextPtr r300,
int dwords, const char *caller)
{
uint32_t *ptr;
@ -82,7 +80,7 @@ static __inline__ uint32_t *r300RawAllocCmdBuf(r300ContextPtr r300,
return ptr;
}
static __inline__ uint32_t *r300AllocCmdBuf(r300ContextPtr r300,
static inline uint32_t *r300AllocCmdBuf(r300ContextPtr r300,
int dwords, const char *caller)
{
uint32_t *ptr;

View file

@ -62,7 +62,7 @@ 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 "r300_mem.h"
@ -447,15 +447,6 @@ 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;

View file

@ -49,13 +49,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define USER_BUFFERS
/* We don't handle 16 bits elts swapping yet */
#ifdef MESA_BIG_ENDIAN
#define FORCE_32BITS_ELTS
#endif
//#define OPTIMIZE_ELTS
struct r300_context;
typedef struct r300_context r300ContextRec;
typedef struct r300_context *r300ContextPtr;
@ -63,13 +56,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__){ \
@ -81,9 +71,6 @@ typedef struct r300_context *r300ContextPtr;
warn##__LINE__=0;\
} \
}
#else
#define WARN_ONCE(a, ...) {}
#endif
#include "r300_vertprog.h"
#include "r300_fragprog.h"
@ -91,7 +78,7 @@ typedef struct r300_context *r300ContextPtr;
/**
* This function takes a float and packs it into a uint32_t
*/
static __inline__ uint32_t r300PackFloat32(float fl)
static inline uint32_t r300PackFloat32(float fl)
{
union {
float fl;
@ -102,6 +89,37 @@ static __inline__ uint32_t r300PackFloat32(float 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:
@ -129,7 +147,6 @@ struct r300_dma_region {
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 {
@ -171,6 +188,8 @@ struct r300_tex_obj {
drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS];
/* Six, for the cube faces */
GLboolean image_override; /* Image overridden by GLX_EXT_tfp */
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 */
@ -433,7 +452,7 @@ struct r300_hw_state {
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 vap_clip;
struct r300_state_atom unk2288; /* (2288) */
struct r300_state_atom pvs; /* pvs_cntl (22D0) */
struct r300_state_atom gb_enable; /* (4008) */
@ -761,50 +780,10 @@ struct r300_fragment_program {
#define R300_MAX_AOS_ARRAYS 16
#define AOS_FORMAT_USHORT 0
#define AOS_FORMAT_FLOAT 1
#define AOS_FORMAT_UBYTE 2
#define AOS_FORMAT_FLOAT_COLOR 3
#define REG_COORDS 0
#define REG_COLOR0 1
#define REG_TEX0 2
struct dt {
GLint size;
GLenum type;
GLsizei stride;
void *data;
};
struct radeon_vertex_buffer {
int Count;
void *Elts;
int elt_size;
int elt_min, elt_max; /* debug */
struct dt AttribPtr[VERT_ATTRIB_MAX];
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;
@ -813,7 +792,6 @@ struct r300_state {
struct r300_pfs_compile_state pfs_compile;
struct r300_dma_region aos[R300_MAX_AOS_ARRAYS];
int aos_count;
struct radeon_vertex_buffer VB;
GLuint *Elts;
struct r300_dma_region elt_dma;
@ -865,9 +843,10 @@ struct r300_context {
#ifdef USER_BUFFERS
struct r300_memory_manager *rmm;
#endif
GLvector4f dummy_attrib[_TNL_ATTRIB_MAX];
GLvector4f *temp_attrib[_TNL_ATTRIB_MAX];
#endif
GLboolean disable_lowimpact_fallback;
};

View file

@ -0,0 +1,534 @@
/*
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.
**************************************************************************/
/**
* \file
*
* \author Keith Whitwell <keith@tungstengraphics.com>
*/
#include "glheader.h"
#include "mtypes.h"
#include "colormac.h"
#include "imports.h"
#include "macros.h"
#include "image.h"
#include "swrast_setup/swrast_setup.h"
#include "math/m_translate.h"
#include "tnl/tnl.h"
#include "tnl/t_context.h"
#include "r300_context.h"
#include "radeon_ioctl.h"
#include "r300_state.h"
#include "r300_emit.h"
#include "r300_ioctl.h"
#ifdef USER_BUFFERS
#include "r300_mem.h"
#endif
#if SWIZZLE_X != R300_INPUT_ROUTE_SELECT_X || \
SWIZZLE_Y != R300_INPUT_ROUTE_SELECT_Y || \
SWIZZLE_Z != R300_INPUT_ROUTE_SELECT_Z || \
SWIZZLE_W != R300_INPUT_ROUTE_SELECT_W || \
SWIZZLE_ZERO != R300_INPUT_ROUTE_SELECT_ZERO || \
SWIZZLE_ONE != R300_INPUT_ROUTE_SELECT_ONE
#error Cannot change these!
#endif
#define DEBUG_ALL DEBUG_VERTS
#if defined(USE_X86_ASM)
#define COPY_DWORDS( dst, src, nr ) \
do { \
int __tmp; \
__asm__ __volatile__( "rep ; movsl" \
: "=%c" (__tmp), "=D" (dst), "=S" (__tmp) \
: "0" (nr), \
"D" ((long)dst), \
"S" ((long)src) ); \
} while (0)
#else
#define COPY_DWORDS( dst, src, nr ) \
do { \
int j; \
for ( j = 0 ; j < nr ; j++ ) \
dst[j] = ((int *)src)[j]; \
dst += nr; \
} while (0)
#endif
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);
if (RADEON_DEBUG & DEBUG_VERTS)
fprintf(stderr, "%s count %d stride %d out %p data %p\n",
__FUNCTION__, count, stride, (void *)out, (void *)data);
if (stride == 4)
COPY_DWORDS(out, data, count);
else
for (i = 0; i < count; i++) {
out[0] = *(int *)data;
out++;
data += stride;
}
}
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);
if (RADEON_DEBUG & DEBUG_VERTS)
fprintf(stderr, "%s count %d stride %d out %p data %p\n",
__FUNCTION__, count, stride, (void *)out, (void *)data);
if (stride == 8)
COPY_DWORDS(out, data, count * 2);
else
for (i = 0; i < count; i++) {
out[0] = *(int *)data;
out[1] = *(int *)(data + 4);
out += 2;
data += stride;
}
}
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);
if (RADEON_DEBUG & DEBUG_VERTS)
fprintf(stderr, "%s count %d stride %d out %p data %p\n",
__FUNCTION__, count, stride, (void *)out, (void *)data);
if (stride == 12)
COPY_DWORDS(out, data, count * 3);
else
for (i = 0; i < count; i++) {
out[0] = *(int *)data;
out[1] = *(int *)(data + 4);
out[2] = *(int *)(data + 8);
out += 3;
data += stride;
}
}
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);
if (RADEON_DEBUG & DEBUG_VERTS)
fprintf(stderr, "%s count %d stride %d out %p data %p\n",
__FUNCTION__, count, stride, (void *)out, (void *)data);
if (stride == 16)
COPY_DWORDS(out, data, count * 4);
else
for (i = 0; i < count; i++) {
out[0] = *(int *)data;
out[1] = *(int *)(data + 4);
out[2] = *(int *)(data + 8);
out[3] = *(int *)(data + 12);
out += 4;
data += stride;
}
}
static void r300EmitVec(GLcontext * ctx, struct r300_dma_region *rvb,
GLvoid * data, int size, int stride, int count)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
if (stride == 0) {
r300AllocDmaRegion(rmesa, rvb, size * 4, 4);
count = 1;
rvb->aos_offset = GET_START(rvb);
rvb->aos_stride = 0;
} else {
r300AllocDmaRegion(rmesa, rvb, size * count * 4, 4);
rvb->aos_offset = GET_START(rvb);
rvb->aos_stride = size;
}
switch (size) {
case 1:
r300EmitVec4(ctx, rvb, data, stride, count);
break;
case 2:
r300EmitVec8(ctx, rvb, data, stride, count);
break;
case 3:
r300EmitVec12(ctx, rvb, data, stride, count);
break;
case 4:
r300EmitVec16(ctx, rvb, data, stride, count);
break;
default:
assert(0);
break;
}
}
static GLuint r300VAPInputRoute0(uint32_t * dst, GLvector4f ** attribptr,
int *inputs, GLint * tab, GLuint nr)
{
GLuint i, dw;
/* type, inputs, stop bit, size */
for (i = 0; i + 1 < nr; i += 2) {
dw = R300_INPUT_ROUTE_FLOAT | (inputs[tab[i]] << 8) | (attribptr[tab[i]]->size - 1);
dw |= (R300_INPUT_ROUTE_FLOAT | (inputs[tab[i + 1]] << 8) | (attribptr[tab[i + 1]]->size - 1)) << 16;
if (i + 2 == nr) {
dw |= (1 << (13 + 16));
}
dst[i >> 1] = dw;
}
if (nr & 1) {
dw = R300_INPUT_ROUTE_FLOAT | (inputs[tab[nr - 1]] << 8) | (attribptr[tab[nr - 1]]->size - 1);
dw |= 1 << 13;
dst[nr >> 1] = dw;
}
return (nr + 1) >> 1;
}
static GLuint r300VAPInputRoute1Swizzle(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);
}
static GLuint r300VAPInputRoute1(uint32_t * dst, int swizzle[][4], GLuint nr)
{
GLuint i;
for (i = 0; i + 1 < nr; i += 2) {
dst[i >> 1] = r300VAPInputRoute1Swizzle(swizzle[i]) | R300_INPUT_ROUTE_ENABLE;
dst[i >> 1] |= (r300VAPInputRoute1Swizzle(swizzle[i + 1]) | R300_INPUT_ROUTE_ENABLE) << 16;
}
if (nr & 1) {
dst[nr >> 1] = r300VAPInputRoute1Swizzle(swizzle[nr - 1]) | R300_INPUT_ROUTE_ENABLE;
}
return (nr + 1) >> 1;
}
static GLuint r300VAPInputCntl0(GLcontext * ctx, GLuint InputsRead)
{
/* No idea what this value means. I have seen other values written to
* this register... */
return 0x5555;
}
static GLuint r300VAPInputCntl1(GLcontext * ctx, GLuint InputsRead)
{
r300ContextPtr rmesa = 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;
rmesa->state.texture.tc_count = 0;
for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
if (InputsRead & (1 << (VERT_ATTRIB_TEX0 + i))) {
rmesa->state.texture.tc_count++;
vic_1 |= R300_INPUT_CNTL_TC0 << i;
}
return vic_1;
}
static GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten)
{
GLuint ret = 0;
if (OutputsWritten & (1 << VERT_RESULT_HPOS))
ret |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT;
if (OutputsWritten & (1 << VERT_RESULT_COL0))
ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT;
if (OutputsWritten & (1 << VERT_RESULT_COL1))
ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT;
#if 0
if (OutputsWritten & (1 << VERT_RESULT_BFC0))
ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT;
if (OutputsWritten & (1 << VERT_RESULT_BFC1))
ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT;
if (OutputsWritten & (1 << VERT_RESULT_FOGC)) ;
#endif
if (OutputsWritten & (1 << VERT_RESULT_PSIZ))
ret |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT;
return ret;
}
static GLuint r300VAPOutputCntl1(GLcontext * ctx, GLuint OutputsWritten)
{
GLuint i, ret = 0;
for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
if (OutputsWritten & (1 << (VERT_RESULT_TEX0 + i))) {
ret |= (4 << (3 * i));
}
}
return ret;
}
/* Emit vertex data to GART memory
* Route inputs to the vertex processor
* This function should never return R300_FALLBACK_TCL when using software tcl.
*/
int r300EmitArrays(GLcontext * ctx)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *vb = &tnl->vb;
GLuint nr;
GLuint count = vb->Count;
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];
struct r300_vertex_program *prog =
(struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx);
if (hw_tcl_on) {
inputs = prog->inputs;
InputsRead = prog->key.InputsRead;
OutputsWritten = prog->key.OutputsWritten;
} else {
inputs = rmesa->state.sw_tcl_inputs;
DECLARE_RENDERINPUTS(render_inputs_bitset);
RENDERINPUTS_COPY(render_inputs_bitset, tnl->render_inputs_bitset);
assert(RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_POS));
assert(RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_NORMAL) == 0);
assert(RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_COLOR0));
if (RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_POS)) {
InputsRead |= 1 << VERT_ATTRIB_POS;
OutputsWritten |= 1 << VERT_RESULT_HPOS;
}
if (RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_COLOR0)) {
InputsRead |= 1 << VERT_ATTRIB_COLOR0;
OutputsWritten |= 1 << VERT_RESULT_COL0;
}
if (RENDERINPUTS_TEST(render_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(render_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;
}
}
if (!(rmesa->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, render_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, 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 (r300IsGartMemory(rmesa, vb->AttribPtr[tab[i]]->data, 4)) {
if (vb->AttribPtr[tab[i]]->stride % 4) {
return R300_FALLBACK_TCL;
}
rmesa->state.aos[i].address = (void *)(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 = vb->AttribPtr[tab[i]]->size;
} else {
r300EmitVec(ctx, &rmesa->state.aos[i],
vb->AttribPtr[tab[i]]->data,
vb->AttribPtr[tab[i]]->size,
vb->AttribPtr[tab[i]]->stride, count);
}
rmesa->state.aos[i].aos_size = vb->AttribPtr[tab[i]]->size;
for (fix = 0; fix <= 4 - vb->AttribPtr[tab[i]]->size; fix++) {
if ((rmesa->state.aos[i].aos_offset - _mesa_sizeof_type(GL_FLOAT) * fix) % 4) {
continue;
}
found = 1;
break;
}
if (found) {
if (fix > 0) {
WARN_ONCE("Feeling lucky?\n");
}
rmesa->state.aos[i].aos_offset -= _mesa_sizeof_type(GL_FLOAT) * 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);
return R300_FALLBACK_TCL;
}
}
/* Setup INPUT_ROUTE. */
R300_STATECHANGE(rmesa, vir[0]);
((drm_r300_cmd_header_t *) rmesa->hw.vir[0].cmd)->packet0.count =
r300VAPInputRoute0(&rmesa->hw.vir[0].cmd[R300_VIR_CNTL_0],
vb->AttribPtr, inputs, tab, nr);
R300_STATECHANGE(rmesa, vir[1]);
((drm_r300_cmd_header_t *) rmesa->hw.vir[1].cmd)->packet0.count =
r300VAPInputRoute1(&rmesa->hw.vir[1].cmd[R300_VIR_CNTL_0], swizzle,
nr);
/* Setup INPUT_CNTL. */
R300_STATECHANGE(rmesa, vic);
rmesa->hw.vic.cmd[R300_VIC_CNTL_0] = r300VAPInputCntl0(ctx, InputsRead);
rmesa->hw.vic.cmd[R300_VIC_CNTL_1] = r300VAPInputCntl1(ctx, InputsRead);
/* Setup OUTPUT_VTX_FMT. */
R300_STATECHANGE(rmesa, vof);
rmesa->hw.vof.cmd[R300_VOF_CNTL_0] =
r300VAPOutputCntl0(ctx, OutputsWritten);
rmesa->hw.vof.cmd[R300_VOF_CNTL_1] =
r300VAPOutputCntl1(ctx, OutputsWritten);
rmesa->state.aos_count = nr;
return R300_FALLBACK_NONE;
}
#ifdef USER_BUFFERS
void r300UseArrays(GLcontext * ctx)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
int 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)
r300_mem_use(rmesa, rmesa->state.aos[i].buf->id);
}
}
#endif
void r300ReleaseArrays(GLcontext * ctx)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
int i;
r300ReleaseDmaRegion(rmesa, &rmesa->state.elt_dma, __FUNCTION__);
for (i = 0; i < rmesa->state.aos_count; i++) {
r300ReleaseDmaRegion(rmesa, &rmesa->state.aos[i], __FUNCTION__);
}
}

View file

@ -44,22 +44,13 @@
#include "r300_cmdbuf.h"
#include "radeon_reg.h"
/*
* CP type-3 packets
*/
#define RADEON_CP_PACKET3_UNK1B 0xC0001B00
#define RADEON_CP_PACKET3_INDX_BUFFER 0xC0003300
#define RADEON_CP_PACKET3_3D_DRAW_VBUF_2 0xC0003400
#define RADEON_CP_PACKET3_3D_DRAW_IMMD_2 0xC0003500
#define RADEON_CP_PACKET3_3D_DRAW_INDX_2 0xC0003600
#define RADEON_CP_PACKET3_3D_LOAD_VBPNTR 0xC0002F00
#define RADEON_CP_PACKET3_3D_CLEAR_ZMASK 0xC0003202
#define RADEON_CP_PACKET3_3D_CLEAR_CMASK 0xC0003802
#define RADEON_CP_PACKET3_3D_CLEAR_HIZ 0xC0003702
/* TODO: move these defines (and the ones from DRM) into r300_reg.h and sync up
* with DRM */
#define CP_PACKET0(reg, n) (RADEON_CP_PACKET0 | ((n)<<16) | ((reg)>>2))
#define CP_PACKET3( pkt, n ) \
(RADEON_CP_PACKET3 | (pkt) | ((n) << 16))
static __inline__ uint32_t cmdpacket0(int reg, int count)
static inline uint32_t cmdpacket0(int reg, int count)
{
drm_r300_cmd_header_t cmd;
@ -71,7 +62,7 @@ static __inline__ uint32_t cmdpacket0(int reg, int count)
return cmd.u;
}
static __inline__ uint32_t cmdvpu(int addr, int count)
static inline uint32_t cmdvpu(int addr, int count)
{
drm_r300_cmd_header_t cmd;
@ -83,7 +74,7 @@ static __inline__ uint32_t cmdvpu(int addr, int count)
return cmd.u;
}
static __inline__ uint32_t cmdpacket3(int packet)
static inline uint32_t cmdpacket3(int packet)
{
drm_r300_cmd_header_t cmd;
@ -93,7 +84,7 @@ static __inline__ uint32_t cmdpacket3(int packet)
return cmd.u;
}
static __inline__ uint32_t cmdcpdelay(unsigned short count)
static inline uint32_t cmdcpdelay(unsigned short count)
{
drm_r300_cmd_header_t cmd;
@ -103,7 +94,7 @@ static __inline__ uint32_t cmdcpdelay(unsigned short count)
return cmd.u;
}
static __inline__ uint32_t cmdwait(unsigned char flags)
static inline uint32_t cmdwait(unsigned char flags)
{
drm_r300_cmd_header_t cmd;
@ -113,7 +104,7 @@ static __inline__ uint32_t cmdwait(unsigned char flags)
return cmd.u;
}
static __inline__ uint32_t cmdpacify(void)
static inline uint32_t cmdpacify(void)
{
drm_r300_cmd_header_t cmd;
@ -134,7 +125,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); \
@ -169,7 +160,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); \
@ -184,7 +175,7 @@ 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) { \
@ -227,40 +218,12 @@ void static inline cp_wait(r300ContextPtr rmesa, unsigned char flags)
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;
extern int r300EmitArrays(GLcontext * ctx);
start_packet3(RADEON_CP_PACKET3_3D_DRAW_VBUF_2, 0);
e32(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (vertex_count << 16)
| type);
}
#ifdef USER_BUFFERS
void r300UseArrays(GLcontext * ctx);
#endif
/**
* 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);
extern void r300ReleaseArrays(GLcontext * ctx);
#endif

View file

@ -57,7 +57,7 @@
*/
#define ERROR(fmt, args...) do { \
fprintf(stderr, "%s::%s(): " fmt "\n", \
__FILE__, __func__, ##args); \
__FILE__, __FUNCTION__, ##args); \
fp->error = GL_TRUE; \
} while(0)

View file

@ -114,7 +114,7 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
(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);
@ -194,6 +194,14 @@ static void r300EmitClearState(GLcontext * ctx)
if (!(r300->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL))
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)
@ -210,31 +218,33 @@ static void r300EmitClearState(GLcontext * ctx)
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) {
R300_STATECHANGE(r300, vte);
/* comes from fglrx startup of clear */
reg_start(R300_SE_VTE_CNTL, 1);
e32(0x043f);
e32(0x8);
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);
}
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(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);
@ -247,12 +257,12 @@ static void r300EmitClearState(GLcontext * ctx)
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);
@ -273,21 +283,21 @@ 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]);
@ -313,7 +323,7 @@ static void r300EmitClearState(GLcontext * ctx)
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(0x0);
e32(1 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT);
R300_STATECHANGE(r300, vpi);
@ -321,12 +331,12 @@ static void r300EmitClearState(GLcontext * ctx)
e32(VP_OUT(ADD, OUT, 0, XYZW));
e32(VP_IN(IN, 0));
e32(VP_ZERO());
e32(0);
e32(0x0);
e32(VP_OUT(ADD, OUT, 1, XYZW));
e32(VP_IN(IN, 1));
e32(VP_ZERO());
e32(0);
e32(0x0);
}
}
@ -667,27 +677,6 @@ 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)
{

View file

@ -39,9 +39,6 @@ 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);

View file

@ -1,665 +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.
**************************************************************************/
/**
* \file
*
* \author Keith Whitwell <keith@tungstengraphics.com>
*/
#include "glheader.h"
#include "mtypes.h"
#include "colormac.h"
#include "imports.h"
#include "macros.h"
#include "image.h"
#include "swrast_setup/swrast_setup.h"
#include "math/m_translate.h"
#include "tnl/tnl.h"
#include "tnl/t_context.h"
#include "r300_context.h"
#include "radeon_ioctl.h"
#include "r300_state.h"
#include "r300_maos.h"
#include "r300_ioctl.h"
#ifdef USER_BUFFERS
#include "r300_mem.h"
#endif
#if SWIZZLE_X != R300_INPUT_ROUTE_SELECT_X || \
SWIZZLE_Y != R300_INPUT_ROUTE_SELECT_Y || \
SWIZZLE_Z != R300_INPUT_ROUTE_SELECT_Z || \
SWIZZLE_W != R300_INPUT_ROUTE_SELECT_W || \
SWIZZLE_ZERO != R300_INPUT_ROUTE_SELECT_ZERO || \
SWIZZLE_ONE != R300_INPUT_ROUTE_SELECT_ONE
#error Cannot change these!
#endif
#define DEBUG_ALL DEBUG_VERTS
#if defined(USE_X86_ASM)
#define COPY_DWORDS( dst, src, nr ) \
do { \
int __tmp; \
__asm__ __volatile__( "rep ; movsl" \
: "=%c" (__tmp), "=D" (dst), "=S" (__tmp) \
: "0" (nr), \
"D" ((long)dst), \
"S" ((long)src) ); \
} while (0)
#else
#define COPY_DWORDS( dst, src, nr ) \
do { \
int j; \
for ( j = 0 ; j < nr ; j++ ) \
dst[j] = ((int *)src)[j]; \
dst += nr; \
} while (0)
#endif
static void emit_vec4(GLcontext * ctx,
struct r300_dma_region *rvb,
GLvoid * data, int stride, int count)
{
int i;
int *out = (int *)(rvb->address + rvb->start);
if (RADEON_DEBUG & DEBUG_VERTS)
fprintf(stderr, "%s count %d stride %d\n",
__FUNCTION__, count, stride);
if (stride == 4)
COPY_DWORDS(out, data, count);
else
for (i = 0; i < count; i++) {
out[0] = *(int *)data;
out++;
data += stride;
}
}
static void emit_vec8(GLcontext * ctx,
struct r300_dma_region *rvb,
GLvoid * data, int stride, int count)
{
int i;
int *out = (int *)(rvb->address + rvb->start);
if (RADEON_DEBUG & DEBUG_VERTS)
fprintf(stderr, "%s count %d stride %d\n",
__FUNCTION__, count, stride);
if (stride == 8)
COPY_DWORDS(out, data, count * 2);
else
for (i = 0; i < count; i++) {
out[0] = *(int *)data;
out[1] = *(int *)(data + 4);
out += 2;
data += stride;
}
}
static void emit_vec12(GLcontext * ctx,
struct r300_dma_region *rvb,
GLvoid * data, int stride, int count)
{
int i;
int *out = (int *)(rvb->address + rvb->start);
if (RADEON_DEBUG & DEBUG_VERTS)
fprintf(stderr, "%s count %d stride %d out %p data %p\n",
__FUNCTION__, count, stride, (void *)out, (void *)data);
if (stride == 12)
COPY_DWORDS(out, data, count * 3);
else
for (i = 0; i < count; i++) {
out[0] = *(int *)data;
out[1] = *(int *)(data + 4);
out[2] = *(int *)(data + 8);
out += 3;
data += stride;
}
}
static void emit_vec16(GLcontext * ctx,
struct r300_dma_region *rvb,
GLvoid * data, int stride, int count)
{
int i;
int *out = (int *)(rvb->address + rvb->start);
if (RADEON_DEBUG & DEBUG_VERTS)
fprintf(stderr, "%s count %d stride %d\n",
__FUNCTION__, count, stride);
if (stride == 16)
COPY_DWORDS(out, data, count * 4);
else
for (i = 0; i < count; i++) {
out[0] = *(int *)data;
out[1] = *(int *)(data + 4);
out[2] = *(int *)(data + 8);
out[3] = *(int *)(data + 12);
out += 4;
data += stride;
}
}
static void emit_vector(GLcontext * ctx,
struct r300_dma_region *rvb,
GLvoid * data, int size, int stride, int count)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
if (RADEON_DEBUG & DEBUG_VERTS)
fprintf(stderr, "%s count %d size %d stride %d\n",
__FUNCTION__, count, size, stride);
/* 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;
} else {
r300AllocDmaRegion(rmesa, rvb, size * count * 4, 4); /* alignment? */
rvb->aos_offset = GET_START(rvb);
rvb->aos_stride = size;
}
/* Emit the data
*/
switch (size) {
case 1:
emit_vec4(ctx, rvb, data, stride, count);
break;
case 2:
emit_vec8(ctx, rvb, data, stride, count);
break;
case 3:
emit_vec12(ctx, rvb, data, stride, count);
break;
case 4:
emit_vec16(ctx, rvb, data, stride, count);
break;
default:
assert(0);
_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");
_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 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;
}
return AOS_FORMAT_FLOAT;
}
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;
}
return 0;
}
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)
{
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;
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 |= 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);
}
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;
}
if (nr & 1)
dst[nr >> 1] =
t_swizzle(swizzle[nr - 1]) | R300_INPUT_ROUTE_ENABLE;
return (nr + 1) >> 1;
}
static GLuint t_emit_size(struct dt *dt)
{
return dt->size;
}
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;
}
/* Emit vertex data to GART memory
* Route inputs to the vertex processor
* This function should never return R300_FALLBACK_TCL when using software tcl.
*/
int r300EmitArrays(GLcontext * ctx)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
r300ContextPtr r300 = rmesa;
struct radeon_vertex_buffer *VB = &rmesa->state.VB;
GLuint nr;
GLuint count = VB->Count;
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);
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));
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));
InputsRead |= 1 << VERT_ATTRIB_COLOR0;
OutputsWritten |= 1 << VERT_RESULT_COL0;
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))) {
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;
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; \
__temp = a;\
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)) {
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].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]]);
} else {
/* TODO: emit_vector 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);
}
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)
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);
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);
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);
/* 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_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;
if (OutputsWritten & (1 << VERT_RESULT_HPOS))
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;
if (OutputsWritten & (1 << VERT_RESULT_COL1))
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; */
//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;
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;
}
#ifdef USER_BUFFERS
void r300UseArrays(GLcontext * ctx)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
int 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)
r300_mem_use(rmesa, rmesa->state.aos[i].buf->id);
}
}
#endif
void r300ReleaseArrays(GLcontext * ctx)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
int i;
r300ReleaseDmaRegion(rmesa, &rmesa->state.elt_dma, __FUNCTION__);
for (i = 0; i < rmesa->state.aos_count; i++) {
r300ReleaseDmaRegion(rmesa, &rmesa->state.aos[i], __FUNCTION__);
}
}

View file

@ -1,50 +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__
#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

View file

@ -45,20 +45,22 @@ 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));
_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_memcpy(rmesa->rmm->u_list, temp,
rmesa->rmm->u_size * sizeof(*rmesa->rmm->u_list));
_mesa_free(temp);
}
rmesa->rmm->u_size = nsize;
}
@ -66,7 +68,7 @@ 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);
}
@ -89,16 +91,17 @@ void *r300_mem_ptr(r300ContextPtr rmesa, int id)
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)
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;
}
@ -108,387 +111,275 @@ 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 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)
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;
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);
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);
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 --) {
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 (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, "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));
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;
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){
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) {
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){
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);
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].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));
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 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;
#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);
}*/
fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id,
radeonGetAge((radeonContextPtr) rmesa));
#endif
cmd = (drm_r300_cmd_header_t *)r300AllocCmdBuf(rmesa, 2 + sizeof(ull) / 4, __FUNCTION__);
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;
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 ++;
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);
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;
}
offset = (char *)rmesa->rmm->u_list[id].ptr -
(char *)rmesa->radeon.radeonScreen->gartTextures.map;
offset += rmesa->radeon.radeonScreen->gart_texture_offset;
return offset;
}
int r300_mem_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 *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
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 = r300_mem_ptr(rmesa, id);
return ptr;
}
if (access == R300_MEM_R) {
if(rmesa->rmm->u_list[id].mapped == 1)
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)
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));
rmesa->rmm->u_list[id].age,
radeonGetAge((radeonContextPtr) rmesa));
return NULL;
}
if(rmesa->rmm->u_list[id].mapped == 1)
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
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)
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 r300_mem_free(r300ContextPtr rmesa, int id)
{
#ifdef MM_DEBUG
fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id, radeonGetAge((radeonContextPtr)rmesa));
#endif
fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id,
radeonGetAge((radeonContextPtr) rmesa));
#endif
assert(id <= rmesa->rmm->u_last);
if(id == 0)
if (id == 0)
return;
if(rmesa->rmm->u_list[id].ptr == NULL){
if (rmesa->rmm->u_list[id].ptr == NULL) {
WARN_ONCE("Not allocated!\n");
return ;
return;
}
if(rmesa->rmm->u_list[id].pending){
if (rmesa->rmm->u_list[id].pending) {
WARN_ONCE("%p already pended!\n", rmesa->rmm->u_list[id].ptr);
return ;
return;
}
rmesa->rmm->u_list[id].pending = 1;
}
#endif

View file

@ -18,11 +18,9 @@ struct r300_memory_manager {
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;
int u_head, u_size, u_last;
};
extern void r300_mem_init(r300ContextPtr rmesa);
@ -32,7 +30,6 @@ 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 int r300_mem_on_card(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);

View file

@ -23,11 +23,11 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
/* *INDENT-OFF* */
#ifndef _R300_REG_H
#define _R300_REG_H
/* *INDENT-OFF* */
#define R300_MC_INIT_MISC_LAT_TIMER 0x180
# define R300_MC_MISC__MC_CPR_INIT_LAT_SHIFT 0
# define R300_MC_MISC__MC_VF_INIT_LAT_SHIFT 4
@ -116,6 +116,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT (1<<16) /* GUESS */
#define R300_VAP_OUTPUT_VTX_FMT_1 0x2094
/* each of the following is 3 bits wide, specifies number
of components */
# define R300_VAP_OUTPUT_VTX_FMT_1__TEX_0_COMP_CNT_SHIFT 0
# define R300_VAP_OUTPUT_VTX_FMT_1__TEX_1_COMP_CNT_SHIFT 3
# define R300_VAP_OUTPUT_VTX_FMT_1__TEX_2_COMP_CNT_SHIFT 6
@ -299,6 +301,18 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_221C_NORMAL 0x00000000
# define R300_221C_CLEAR 0x0001C000
/* These seem to be per-pixel and per-vertex X and Y clipping planes. The first
* plane is per-pixel and the second plane is per-vertex.
*
* This was determined by experimentation alone but I believe it is correct.
*
* These registers are called X_QUAD0_1_FL to X_QUAD0_4_FL by glxtest.
*/
#define R300_VAP_CLIP_X_0 0x2220
#define R300_VAP_CLIP_X_1 0x2224
#define R300_VAP_CLIP_Y_0 0x2228
#define R300_VAP_CLIP_Y_1 0x2230
/* gap */
/* Sometimes, END_OF_PKT and 0x2284=0 are the only commands sent between
@ -673,6 +687,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
@ -962,7 +981,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
* first node is stored in NODE_2, the second node is stored in NODE_3.
*
* Offsets are relative to the master offset from PFS_CNTL_2.
* LAST_NODE is set for the last node, and only for the last node.
*/
#define R300_PFS_NODE_0 0x4610
#define R300_PFS_NODE_1 0x4614
@ -976,7 +994,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_PFS_NODE_TEX_OFFSET_MASK (31 << 12)
# define R300_PFS_NODE_TEX_END_SHIFT 17
# define R300_PFS_NODE_TEX_END_MASK (31 << 17)
/*# define R300_PFS_NODE_LAST_NODE (1 << 22) */
# define R300_PFS_NODE_OUTPUT_COLOR (1 << 22)
# define R300_PFS_NODE_OUTPUT_DEPTH (1 << 23)
@ -1586,6 +1603,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_EB_UNK1_SHIFT 24
# define R300_EB_UNK1 (0x80<<24)
# define R300_EB_UNK2 0x0810
#define R300_PACKET3_3D_DRAW_VBUF_2 0x00003400
#define R300_PACKET3_3D_DRAW_INDX_2 0x00003600
/* END: Packet 3 commands */
@ -1606,6 +1624,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define R300_CP_CMD_BITBLT_MULTI 0xC0009B00
/* *INDENT-ON* */
#endif /* _R300_REG_H */
/* *INDENT-ON* */

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