Merge commit 'origin/gallium-0.2' into gallium-xlib-rework

Conflicts:

	progs/glsl/Makefile
This commit is contained in:
Keith Whitwell 2009-01-09 10:08:06 +00:00
commit e3734593ae
126 changed files with 3212 additions and 1523 deletions

View file

@ -324,7 +324,7 @@ MAIN_FILES = \
DRI_FILES = \
$(DIRECTORY)/include/GL/internal/dri_interface.h \
$(DIRECTORY)/include/GL/internal/dri_sarea.h \
$(DIRECTORY)/include/GL/internal/glcore.h \
$(DIRECTORY)/include/GL/internal/sarea.h \
$(DIRECTORY)/src/glx/Makefile \
$(DIRECTORY)/src/glx/x11/Makefile \

View file

@ -37,8 +37,8 @@ a:visited {
<b>Download / Install</b>
<ul>
<li><a href="download.html" target="MainFrame">Downloading/Unpacking</a>
<li><a href="install.html" target="MainFrame">Compilation/Installation</a>
<li><a href="download.html" target="MainFrame">Downloading / Unpacking</a>
<li><a href="install.html" target="MainFrame">Compiling / Installing</a>
<li><a href="glu.html" target="MainFrame">SGI's GLU</a>
<li><a href="precompiled.html" target="MainFrame">Precompiled Libraries</a>
</ul>

View file

@ -1,58 +1,72 @@
<HTML>
<TITLE>Compilation and Installation</TITLE>
<TITLE>Compiling and Installing</TITLE>
<link rel="stylesheet" type="text/css" href="mesa.css"></head>
<BODY>
<H1>Compilation and Installation</H1>
<H1>Compiling and Installing</H1>
<ol>
<li><a href="#unix-x11">Unix / X11</a>
<ul>
<li><a href="#prereq">Prerequisites for DRI and hardware acceleration</a>
<li><a href="#autoconf">Building with autoconf</a>
<li><a href="#traditional">Building with traditional Makefiles</a>
<li><a href="#libs">The Libraries</a>
<li><a href="#demos">Running the demos
<li><a href="#install">Installing the header and library files
<li><a href="#pkg-config">Building OpenGL programs with pkg-config
</ul>
<li><a href="#windows">Windows</a>
<li><a href="#vms">VMS</a>
<li><a href="#other">Other</a>
</ol>
<br>
<a name="unix-x11">
<H2>1. Unix/X11 Compilation and Installation</H1>
<h3>1.1 Prerequisites for DRI and Hardware Acceleration</h3>
<a name="prereq">
<h3>1.1 Prerequisites for DRI and hardware acceleration</h3>
<p>
To build Mesa 7.1 with DRI-based hardware acceleration you must first have
the <a href="http://dri.freedesktop.org/libdrm/" target="_parent">DRM version 2.3.1</a>.
The following are required for DRI-based hardware acceleration with Mesa 7.3:
</p>
<p>
You should also be using the Xorg server version 1.4 or 1.5.
<ul>
<li><a href="http://xorg.freedesktop.org/releases/individual/proto/">driproto2</a> version 1.99.3 or later
<li><a href="http://dri.freedesktop.org/libdrm/" target="_parent">DRM</a>
version 2.4.3 or later
<li>Xorg server version 1.4 or 1.5.
</ul>
</p>
<h3>1.2 Autoconf Compilation</h3>
<a name="autoconf">
<h3>1.2 Building with Autoconf</h3>
<p>
Mesa may be <a href="autoconf.html">built using autoconf</a>.
This should work well on most GNU-based systems.
When that fails, the traditional Mesa build system is available.
If that fails the traditional Mesa build system is available.
<h3>1.3 Traditional Compilation</h3>
<a name="traditional">
<h3>1.3 Building with traditional Makefiles</h3>
<p>
The traditional Mesa build system is based on a collection of pre-defined
system configurations.
</p>
<p>
To see the list of configurations, type <b>make</b> alone.
Then choose a configuration from the list and type <b>make configname</b>.
To see the list of configurations, just type <code>make</code>.
Then choose a configuration from the list and type <code>make</code>
<em>configname</em>.
</p>
<p>
@ -66,7 +80,7 @@ allow you to run OpenGL/GLX applications on any X server (regardless of
whether it supports the GLX X server extension).
You will <em>not</em> be able to use hardware 3D acceleration.
<p>
To compile stand-alone Mesa type <b>make</b> in the top-level directory.
To compile stand-alone Mesa type <code>make</code> in the top-level directory.
You'll see a list of supported system configurations.
Choose one from the list (such as linux-x86), and type:
</p>
@ -109,6 +123,7 @@ Later, if you want to rebuild for a different configuration run
</p>
<a name="libs">
<h3>1.4 The libraries</h3>
<p>
@ -169,6 +184,7 @@ If you built the DRI hardware drivers, you'll also see the DRI drivers:
</pre>
<a name="demos">
<h3>1.5 Running the demos</h3>
<p>
@ -244,6 +260,7 @@ Retrace your steps if this doesn't look right.
</p>
<a name="install">
<H3>1.6 Installing the header and library files</H3>
<p>
@ -284,7 +301,8 @@ This is a handy way to compare multiple OpenGL implementations.
</p>
<H3>1.7 Building OpenGL Programs With pkg-config</H3>
<a name="pkg-config">
<H3>1.7 Building OpenGL programs with pkg-config</H3>
<p>
Running <code>make install</code> will install package configuration files
@ -314,25 +332,15 @@ Please see the <a href="README.WIN32">README.WIN32</a> file.
<a name="vms">
<H2>3. VMS Compilation and Installation</H1>
<p>
Please see the <a href="README.VMS">README.VMS</a> file.
</p>
<a name="other">
<H2>4. Other systems</H1>
<H2>3. Other systems</H1>
<p>
Documentation for other environments (some may be very out of date):
</p>
<UL>
<li><A HREF="README.VMS">README.VMS</A> - VMS
<LI><A HREF="README.GGI">README.GGI</A> - GGI
<LI><A HREF="README.3DFX">README.3DFX</A> - 3Dfx/Glide driver
<LI><A HREF="README.AMIWIN">README.AMIWIN</A> - Amiga Amiwin

View file

@ -21,3 +21,5 @@ texdemo1
toyball
trirast
twoside
vert-or-frag-only
vert-tex

View file

@ -23,6 +23,7 @@ PROGS = \
noise \
points \
pointcoord \
samplers \
skinning \
texdemo1 \
toyball \
@ -119,10 +120,10 @@ identity: identity.o shaderutil.o
fragcoord.o: fragcoord.c extfuncs.h shaderutil.h
$(CC) -c -I$(INCDIR) $(CFLAGS) fragcoord.c
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) fragcoord.c
fragcoord: fragcoord.o shaderutil.o
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) fragcoord.o shaderutil.o $(LIBS) -o $@
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) fragcoord.o shaderutil.o $(LIBS) -o $@
mandelbrot.o: mandelbrot.c extfuncs.h shaderutil.h
@ -159,6 +160,13 @@ pointcoord: pointcoord.o readtex.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) pointcoord.o readtex.o shaderutil.o $(LIBS) -o $@
samplers.o: samplers.c readtex.h extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) samplers.c
samplers: samplers.o readtex.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) samplers.o readtex.o shaderutil.o $(LIBS) -o $@
skinning.o: skinning.c readtex.h extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) skinning.c
@ -201,8 +209,6 @@ vert-or-frag-only: vert-or-frag-only.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) vert-or-frag-only.o shaderutil.o $(LIBS) -o $@
vert-tex.o: vert-tex.c extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) vert-tex.c

357
progs/glsl/samplers.c Normal file
View file

@ -0,0 +1,357 @@
/**
* Exercise all available GLSL texture samplers.
*
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, 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.
*/
/**
* We generate a fragment shader which uses the maximum number of supported
* texture samplers.
* For each sampler we create a separate texture. Each texture has a
* single strip of color at a different intensity. The fragment shader
* samples all the textures at the same coordinate and sums the values.
* The result should be a quad with rows of colors of increasing intensity
* from bottom to top.
*
* Brian Paul
* 1 Jan 2009
*/
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "GL/glut.h"
#include "readtex.h"
#include "extfuncs.h"
#include "shaderutil.h"
#define MAX_SAMPLERS 128
static const char *Demo = "samplers";
static GLuint Program;
static GLint NumSamplers;
static GLuint Textures[MAX_SAMPLERS];
static GLfloat Xrot = 0.0, Yrot = .0, Zrot = 0.0;
static GLfloat EyeDist = 10;
static GLboolean Anim = GL_FALSE;
static void
DrawPolygon(GLfloat size)
{
glPushMatrix();
glNormal3f(0, 0, 1);
glBegin(GL_POLYGON);
glMultiTexCoord2f(GL_TEXTURE0, 0, 0);
glVertex2f(-size, -size);
glMultiTexCoord2f(GL_TEXTURE0, 1, 0);
glVertex2f( size, -size);
glMultiTexCoord2f(GL_TEXTURE0, 1, 1);
glVertex2f( size, size);
glMultiTexCoord2f(GL_TEXTURE0, 0, 1);
glVertex2f(-size, size);
glEnd();
glPopMatrix();
}
static void
draw(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef(0.0, 0.0, -EyeDist);
glRotatef(Zrot, 0, 0, 1);
glRotatef(Yrot, 0, 1, 0);
glRotatef(Xrot, 1, 0, 0);
DrawPolygon(3.0);
glPopMatrix();
glutSwapBuffers();
}
static void
idle(void)
{
GLfloat t = 0.05 * glutGet(GLUT_ELAPSED_TIME);
Yrot = t;
glutPostRedisplay();
}
static void
key(unsigned char k, int x, int y)
{
(void) x;
(void) y;
switch (k) {
case ' ':
case 'a':
Anim = !Anim;
if (Anim)
glutIdleFunc(idle);
else
glutIdleFunc(NULL);
break;
case 'z':
EyeDist -= 0.5;
if (EyeDist < 3.0)
EyeDist = 3.0;
break;
case 'Z':
EyeDist += 0.5;
if (EyeDist > 90.0)
EyeDist = 90;
break;
case 27:
exit(0);
}
glutPostRedisplay();
}
static void
specialkey(int key, int x, int y)
{
GLfloat step = 2.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();
}
/* new window size or exposure */
static void
Reshape(int width, int height)
{
GLfloat ar = (float) width / (float) height;
glViewport(0, 0, (GLint)width, (GLint)height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-2.0*ar, 2.0*ar, -2.0, 2.0, 4.0, 100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
static void
InitTextures(void)
{
const GLint size = MAX_SAMPLERS;
GLubyte *texImage;
GLenum filter = GL_NEAREST;
GLint stripeSize;
GLint s;
texImage = (GLubyte *) malloc(size * size * 4);
glGenTextures(NumSamplers, Textures);
/* size of texels stripe */
stripeSize = size / NumSamplers;
/* create a texture for each sampler */
for (s = 0; s < NumSamplers; s++) {
GLint x, y, ypos;
GLubyte intensity = 31 + s * (256-32) / (NumSamplers - 1);
printf("Texture %d: color = %d, %d, %d\n", s,
(int) intensity, 0, (int) intensity );
/* initialize the texture to black */
memset(texImage, 0, size * size * 4);
/* set a stripe of texels to the intensity value */
ypos = s * stripeSize;
for (y = 0; y < stripeSize; y++) {
for (x = 0; x < size; x++) {
GLint k = 4 * ((ypos + y) * size + x);
texImage[k + 0] = intensity;
texImage[k + 1] = intensity;
texImage[k + 2] = 0;
texImage[k + 3] = 255;
}
}
glActiveTexture(GL_TEXTURE0 + s);
glBindTexture(GL_TEXTURE_2D, Textures[s]);
gluBuild2DMipmaps(GL_TEXTURE_2D, 4, size, size,
GL_RGBA, GL_UNSIGNED_BYTE, texImage);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
}
free(texImage);
}
/**
* Generate a fragment shader that uses the given number of samplers.
*/
static char *
GenFragmentShader(GLint numSamplers)
{
const int maxLen = 10 * 1000;
char *prog = (char *) malloc(maxLen);
char *p = prog;
int s;
p += sprintf(p, "// Generated fragment shader:\n");
for (s = 0; s < numSamplers; s++) {
p += sprintf(p, "uniform sampler2D tex%d;\n", s);
}
p += sprintf(p, "void main()\n");
p += sprintf(p, "{\n");
p += sprintf(p, " vec4 color = vec4(0.0);\n");
for (s = 0; s < numSamplers; s++) {
p += sprintf(p, " color += texture2D(tex%d, gl_TexCoord[0].xy);\n", s);
}
p += sprintf(p, " gl_FragColor = color;\n");
p += sprintf(p, "}\n");
assert(p - prog < maxLen);
return prog;
}
/** Create & bind shader program */
static GLuint
CreateProgram(void)
{
GLuint fragShader, vertShader, program;
const char *vertShaderText =
"void main() \n"
"{ \n"
" gl_TexCoord[0] = gl_MultiTexCoord0; \n"
" gl_Position = ftransform(); \n"
"} \n";
char *fragShaderText = GenFragmentShader(NumSamplers);
printf("%s", fragShaderText);
vertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
assert(vertShader);
program = LinkShaders(vertShader, fragShader);
glUseProgram_func(program);
free(fragShaderText);
return program;
}
static void
InitProgram(void)
{
GLint s;
Program = CreateProgram();
/* init sampler uniforms */
for (s = 0; s < NumSamplers; s++) {
char uname[10];
GLint loc;
sprintf(uname, "tex%d", s);
loc = glGetUniformLocation_func(Program, uname);
assert(loc >= 0);
glUniform1i_func(loc, s);
}
}
static void
InitGL(void)
{
if (!ShadersSupported()) {
printf("GLSL not supported!\n");
exit(1);
}
printf("GL_RENDERER = %s\n", (const char *) glGetString(GL_RENDERER));
GetExtensionFuncs();
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &NumSamplers);
if (NumSamplers > MAX_SAMPLERS)
NumSamplers = MAX_SAMPLERS;
printf("Testing %d samplers\n", NumSamplers);
InitTextures();
InitProgram();
glClearColor(.6, .6, .9, 0);
glColor3f(1.0, 1.0, 1.0);
printf("Each color corresponds to a separate sampler/texture.\n");
}
int
main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowSize(500, 400);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
glutCreateWindow(Demo);
glutReshapeFunc(Reshape);
glutKeyboardFunc(key);
glutSpecialFunc(specialkey);
glutDisplayFunc(draw);
if (Anim)
glutIdleFunc(idle);
InitGL();
glutMainLoop();
return 0;
}

View file

@ -26,27 +26,39 @@ static GLuint fragShader;
static GLuint vertShader;
static GLuint program;
static GLint win = 0;
static GLboolean anim = 0*GL_TRUE;
static GLboolean DetermineInFragProg = GL_TRUE;
static GLfloat Xrot = 30.0f;
static GLboolean anim;
static GLboolean DetermineFacingInFragProg;
static GLfloat Xrot;
static GLint u_fragface;
static GLenum FrontWinding = GL_CCW;
static GLenum FrontWinding;
static int prevTime = 0;
static const GLfloat Red[4] = {1, 0, 0, 0};
static const GLfloat Red[4] = {1, 0, 0, 1};
static const GLfloat Green[4] = {0, 1, 0, 0};
static void
SetDefaults(void)
{
DetermineFacingInFragProg = GL_TRUE;
FrontWinding = GL_CCW;
Xrot = 30;
anim = 0;
glutIdleFunc(NULL);
}
static void
Redisplay(void)
{
const int sections = 20;
int i;
float radius = 2;
glFrontFace(FrontWinding);
if (DetermineInFragProg) {
if (DetermineFacingInFragProg) {
glUniform1i_func(u_fragface, 1);
glDisable(GL_VERTEX_PROGRAM_TWO_SIDE);
}
@ -64,8 +76,8 @@ Redisplay(void)
glBegin(GL_TRIANGLE_STRIP);
glColor4fv(Red);
glSecondaryColor3fv_func(Green);
for (i = 0; i < 20; i++) {
float a = i / 19.0 * M_PI * 2.0;
for (i = 0; i <= sections; i++) {
float a = (float) i / (sections) * M_PI * 2.0;
float x = radius * cos(a);
float y = radius * sin(a);
glVertex3f(x, -1, y);
@ -139,17 +151,15 @@ Key(unsigned char key, int x, int y)
break;
case 'f':
printf("Using frag shader gl_FrontFacing\n");
DetermineInFragProg = GL_TRUE;
DetermineFacingInFragProg = GL_TRUE;
break;
case 'v':
printf("Using vert shader Two-sided lighting\n");
DetermineInFragProg = GL_FALSE;
DetermineFacingInFragProg = GL_FALSE;
break;
case 'r':
/* reset */
Xrot = 30;
anim = 0;
glutIdleFunc(NULL);
SetDefaults();
break;
case 's':
Xrot += 5;
@ -182,14 +192,16 @@ Init(void)
static const char *fragShaderText =
"uniform bool fragface; \n"
"void main() { \n"
#if 0
#if 1
" if (!fragface || gl_FrontFacing) { \n"
" gl_FragColor = gl_Color; \n"
" } \n"
" else { \n"
" // note: dim green to help debug \n"
" gl_FragColor = 0.8 * gl_SecondaryColor; \n"
" } \n"
#else
/* DEBUG CODE */
" bool f = gl_FrontFacing; \n"
" if (f) { \n"
" gl_FragColor = vec4(1.0, 0.0, 0.0, 0.0); \n"
@ -197,8 +209,6 @@ Init(void)
" else { \n"
" gl_FragColor = vec4(0.0, 1.0, 0.0, 0.0); \n"
" } \n"
" //float g = float(gl_FrontFacing) * 0.5 + 0.5; \n"
" //gl_FragColor = vec4(g); \n"
#endif
"} \n";
static const char *vertShaderText =
@ -241,6 +251,8 @@ Init(void)
assert(glIsShader_func(vertShader));
glEnable(GL_DEPTH_TEST);
SetDefaults();
}

View file

@ -313,6 +313,7 @@ def generate(env):
'-Wmissing-prototypes',
'-Wno-long-long',
'-ffast-math',
'-std=c99',
'-pedantic',
'-fmessage-length=0', # be nice to Eclipse
]
@ -391,6 +392,16 @@ def generate(env):
env.Append(CFLAGS = cflags)
env.Append(CXXFLAGS = cflags)
if env['platform'] == 'windows' and msvc:
# Choose the appropriate MSVC CRT
# http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
if env['debug']:
env.Append(CCFLAGS = ['/MTd'])
env.Append(SHCCFLAGS = ['/LDd'])
else:
env.Append(CCFLAGS = ['/MT'])
env.Append(SHCCFLAGS = ['/LD'])
# Assembler options
if gcc:
if env['machine'] == 'x86':

View file

@ -458,6 +458,16 @@ def generate(env):
env.Append(CFLAGS = cflags)
env.Append(CXXFLAGS = cflags)
if env['platform'] == 'windows' and msvc:
# Choose the appropriate MSVC CRT
# http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
if env['debug']:
env.Append(CCFLAGS = ['/MTd'])
env.Append(SHCCFLAGS = ['/LDd'])
else:
env.Append(CCFLAGS = ['/MT'])
env.Append(SHCCFLAGS = ['/LD'])
# Assembler options
if gcc:
if env['machine'] == 'x86':

View file

@ -33,6 +33,7 @@
#include "draw_private.h"
#include "draw_pipe.h"
#include "draw_context.h"
#include "draw_vbuf.h"
static boolean points( unsigned prim )
{
@ -52,16 +53,28 @@ static boolean triangles( unsigned prim )
}
/**
* Check if we need any special pipeline stages, or whether
* prims/verts can go through untouched. Don't test for bypass
* clipping or vs modes, this function is just about the primitive
* pipeline stages.
* Default version of a function to check if we need any special
* pipeline stages, or whether prims/verts can go through untouched.
* Don't test for bypass clipping or vs modes, this function is just
* about the primitive pipeline stages.
*
* This can be overridden by the driver.
*/
boolean
draw_need_pipeline(const struct draw_context *draw,
const struct pipe_rasterizer_state *rasterizer,
unsigned int prim )
{
/* If the driver has overridden this, use that version:
*/
if (draw->render &&
draw->render->need_pipeline)
{
return draw->render->need_pipeline( draw->render,
rasterizer,
prim );
}
/* Don't have to worry about triangles turning into lines/points
* and triggering the pipeline, because we have to trigger the
* pipeline *anyway* if unfilled mode is active.

View file

@ -30,7 +30,7 @@
* Vertex buffer drawing stage.
*
* \author Keith Whitwell <keith@tungstengraphics.com>
* \author José Fonseca <jrfonsec@tungstengraphics.com>
* \author Jose Fonseca <jrfonsec@tungstengraphics.com>
*/
#ifndef DRAW_VBUF_H_
@ -38,6 +38,7 @@
struct pipe_rasterizer_state;
struct draw_context;
struct vertex_info;
@ -54,6 +55,17 @@ struct vbuf_render {
unsigned max_indices;
unsigned max_vertex_buffer_bytes;
/**
* Query if the hardware driver needs assistance for a particular
* combination of rasterizer state and primitive.
*
* Currently optional.
*/
boolean (*need_pipeline)(const struct vbuf_render *render,
const struct pipe_rasterizer_state *rasterizer,
unsigned int prim );
/**
* Get the hardware vertex format.
*

View file

@ -81,9 +81,9 @@ struct vertex_info
* memcmp() comparisons.
*/
struct {
ubyte interp_mode:4; /**< INTERP_x */
ubyte emit:4; /**< EMIT_x */
ubyte src_index; /**< map to post-xform attribs */
unsigned interp_mode:4; /**< INTERP_x */
unsigned emit:4; /**< EMIT_x */
unsigned src_index:8; /**< map to post-xform attribs */
} attrib[PIPE_MAX_SHADER_INPUTS];
};

View file

@ -50,7 +50,7 @@ void draw_vs_set_constants( struct draw_context *draw,
const float (*constants)[4],
unsigned size )
{
if (((unsigned)constants) & 0xf) {
if (((uintptr_t)constants) & 0xf) {
if (size > draw->vs.const_storage_size) {
if (draw->vs.aligned_constant_storage)
align_free((void *)draw->vs.aligned_constant_storage);

View file

@ -261,7 +261,7 @@ emit_vx(struct ppc_function *p, uint op2, uint vD, uint vA, uint vB)
inst.inst.vB = vB;
inst.inst.op2 = op2;
emit_instruction(p, inst.bits);
};
}
union vxr_inst {
@ -287,7 +287,7 @@ emit_vxr(struct ppc_function *p, uint op2, uint vD, uint vA, uint vB)
inst.inst.rC = 0;
inst.inst.op2 = op2;
emit_instruction(p, inst.bits);
};
}
union va_inst {
@ -313,7 +313,7 @@ emit_va(struct ppc_function *p, uint op2, uint vD, uint vA, uint vB, uint vC)
inst.inst.vC = vC;
inst.inst.op2 = op2;
emit_instruction(p, inst.bits);
};
}
union i_inst {
@ -430,7 +430,7 @@ emit_d(struct ppc_function *p, uint op, uint rt, uint ra, int si)
inst.inst.ra = ra;
inst.inst.si = (unsigned) (si & 0xffff);
emit_instruction(p, inst.bits);
};
}
union a_inst {
@ -459,7 +459,7 @@ emit_a(struct ppc_function *p, uint op, uint frt, uint fra, uint frb, uint op2,
inst.inst.op2 = op2;
inst.inst.rc = rc;
emit_instruction(p, inst.bits);
};
}
union xo_inst {

View file

@ -180,14 +180,16 @@ _dump_register_ind(
uint file,
int index,
uint ind_file,
int ind_index )
int ind_index,
uint ind_swizzle )
{
ENM( file, file_names );
CHR( '[' );
ENM( ind_file, file_names );
CHR( '[' );
SID( ind_index );
CHR( ']' );
TXT( "]." );
ENM( ind_swizzle, swizzle_names );
if (index != 0) {
if (index > 0)
CHR( '+' );
@ -385,7 +387,8 @@ iter_instruction(
src->SrcRegister.File,
src->SrcRegister.Index,
src->SrcRegisterInd.File,
src->SrcRegisterInd.Index );
src->SrcRegisterInd.Index,
src->SrcRegisterInd.SwizzleX );
}
else {
_dump_register(

View file

@ -646,7 +646,6 @@ tgsi_dump_c(
struct tgsi_full_declaration fd;
uint ignored = flags & TGSI_DUMP_C_IGNORED;
uint deflt = flags & TGSI_DUMP_C_DEFAULT;
uint instno = 0;
tgsi_parse_init( &parse, tokens );

View file

@ -124,7 +124,7 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
/* only first 32 regs will appear in this bitfield */
info->file_mask[file] |= (1 << reg);
info->file_count[file]++;
info->file_max[file] = MAX2(info->file_max[file], (int)i);
info->file_max[file] = MAX2(info->file_max[file], (int)reg);
if (file == TGSI_FILE_INPUT) {
info->input_semantic_name[reg] = (ubyte)fulldecl->Semantic.SemanticName;

View file

@ -23,6 +23,7 @@ util = env.ConvenienceLibrary(
'u_stream_wd.c',
'u_tile.c',
'u_time.c',
'u_timed_winsys.c',
])
auxiliaries.insert(0, util)

View file

@ -1198,7 +1198,7 @@ make_3d_mipmap(struct gen_mipmap_state *ctx,
{
struct pipe_context *pipe = ctx->pipe;
struct pipe_screen *screen = pipe->screen;
uint dstLevel, zslice;
uint dstLevel, zslice = 0;
assert(pt->block.width == 1);
assert(pt->block.height == 1);

View file

@ -162,7 +162,7 @@ cell_create_context(struct pipe_screen *screen,
*/
/* This call only works with SDK 3.0. Anyone still using 2.1??? */
cell->num_cells = spe_cpu_info_get(SPE_COUNT_PHYSICAL_CPU_NODES, -1);
cell->num_spus = spe_cpu_info_get(SPE_COUNT_USABLE_SPES, 0);
cell->num_spus = spe_cpu_info_get(SPE_COUNT_USABLE_SPES, -1);
if (cell->debug_flags) {
printf("Cell: found %d Cell(s) with %u SPUs\n",
cell->num_cells, cell->num_spus);

File diff suppressed because it is too large Load diff

View file

@ -81,8 +81,12 @@ cell_get_param(struct pipe_screen *screen, int param)
return 8; /* max 128x128x128 */
case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
return CELL_MAX_TEXTURE_LEVELS;
case PIPE_CAP_TEXTURE_MIRROR_REPEAT:
return 1; /* XXX not really true */
case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
return 0; /* XXX to do */
default:
return 10;
return 0;
}
}
@ -108,7 +112,7 @@ cell_get_paramf(struct pipe_screen *screen, int param)
return 16.0; /* arbitrary */
default:
return 10;
return 0;
}
}

View file

@ -0,0 +1,186 @@
#ifndef SPU_SHUFFLE_H
#define SPU_SHUFFLE_H
/*
* Generate shuffle patterns with minimal fuss.
*
* Based on ideas from
* http://www.insomniacgames.com/tech/articles/0408/files/shuffles.pdf
*
* A-P indicates 0-15th position in first vector
* a-p indicates 0-15th position in second vector
*
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* |00|01|02|03|04|05|06|07|08|09|0a|0b|0c|0d|0e|0f|
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* | A| B| C| D|
* +-----+-----+-----+-----+-----+-----+-----+-----+
* | A| B| C| D| E| F| G| H|
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* | A| B| C| D| E| F| G| H| I| J| K| L| M| N| O| P|
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
*
* x or X indicates 0xff
* 8 indicates 0x80
* 0 indicates 0x00
*
* The macros SHUFFLE4() SHUFFLE8() and SHUFFLE16() provide a const vector
* unsigned char literal suitable for use with spu_shuffle().
*
* The macros SHUFB4() SHUFB8() and SHUFB16() provide a const qword vector
* literal suitable for use with si_shufb().
*
*
* For example :
* SHUFB4(A,A,A,A)
* expands to :
* ((const qword){0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3})
*
* SHUFFLE8(A,B,a,b,C,c,8,8)
* expands to :
* ((const vector unsigned char){0x00,0x01,0x02,0x03,0x10,0x11,0x12,0x13,
* 0x04,0x05,0x14,0x15,0xe0,0xe0,0xe0,0xe0})
*
*/
#include <spu_intrinsics.h>
#define SHUFFLE_PATTERN_4_A__ 0x00, 0x01, 0x02, 0x03
#define SHUFFLE_PATTERN_4_B__ 0x04, 0x05, 0x06, 0x07
#define SHUFFLE_PATTERN_4_C__ 0x08, 0x09, 0x0a, 0x0b
#define SHUFFLE_PATTERN_4_D__ 0x0c, 0x0d, 0x0e, 0x0f
#define SHUFFLE_PATTERN_4_a__ 0x10, 0x11, 0x12, 0x13
#define SHUFFLE_PATTERN_4_b__ 0x14, 0x15, 0x16, 0x17
#define SHUFFLE_PATTERN_4_c__ 0x18, 0x19, 0x1a, 0x1b
#define SHUFFLE_PATTERN_4_d__ 0x1c, 0x1d, 0x1e, 0x1f
#define SHUFFLE_PATTERN_4_X__ 0xc0, 0xc0, 0xc0, 0xc0
#define SHUFFLE_PATTERN_4_x__ 0xc0, 0xc0, 0xc0, 0xc0
#define SHUFFLE_PATTERN_4_0__ 0x80, 0x80, 0x80, 0x80
#define SHUFFLE_PATTERN_4_8__ 0xe0, 0xe0, 0xe0, 0xe0
#define SHUFFLE_VECTOR_4__(A, B, C, D) \
SHUFFLE_PATTERN_4_##A##__, \
SHUFFLE_PATTERN_4_##B##__, \
SHUFFLE_PATTERN_4_##C##__, \
SHUFFLE_PATTERN_4_##D##__
#define SHUFFLE4(A, B, C, D) \
((const vector unsigned char){ \
SHUFFLE_VECTOR_4__(A, B, C, D) \
})
#define SHUFB4(A, B, C, D) \
((const qword){ \
SHUFFLE_VECTOR_4__(A, B, C, D) \
})
#define SHUFFLE_PATTERN_8_A__ 0x00, 0x01
#define SHUFFLE_PATTERN_8_B__ 0x02, 0x03
#define SHUFFLE_PATTERN_8_C__ 0x04, 0x05
#define SHUFFLE_PATTERN_8_D__ 0x06, 0x07
#define SHUFFLE_PATTERN_8_E__ 0x08, 0x09
#define SHUFFLE_PATTERN_8_F__ 0x0a, 0x0b
#define SHUFFLE_PATTERN_8_G__ 0x0c, 0x0d
#define SHUFFLE_PATTERN_8_H__ 0x0e, 0x0f
#define SHUFFLE_PATTERN_8_a__ 0x10, 0x11
#define SHUFFLE_PATTERN_8_b__ 0x12, 0x13
#define SHUFFLE_PATTERN_8_c__ 0x14, 0x15
#define SHUFFLE_PATTERN_8_d__ 0x16, 0x17
#define SHUFFLE_PATTERN_8_e__ 0x18, 0x19
#define SHUFFLE_PATTERN_8_f__ 0x1a, 0x1b
#define SHUFFLE_PATTERN_8_g__ 0x1c, 0x1d
#define SHUFFLE_PATTERN_8_h__ 0x1e, 0x1f
#define SHUFFLE_PATTERN_8_X__ 0xc0, 0xc0
#define SHUFFLE_PATTERN_8_x__ 0xc0, 0xc0
#define SHUFFLE_PATTERN_8_0__ 0x80, 0x80
#define SHUFFLE_PATTERN_8_8__ 0xe0, 0xe0
#define SHUFFLE_VECTOR_8__(A, B, C, D, E, F, G, H) \
SHUFFLE_PATTERN_8_##A##__, \
SHUFFLE_PATTERN_8_##B##__, \
SHUFFLE_PATTERN_8_##C##__, \
SHUFFLE_PATTERN_8_##D##__, \
SHUFFLE_PATTERN_8_##E##__, \
SHUFFLE_PATTERN_8_##F##__, \
SHUFFLE_PATTERN_8_##G##__, \
SHUFFLE_PATTERN_8_##H##__
#define SHUFFLE8(A, B, C, D, E, F, G, H) \
((const vector unsigned char){ \
SHUFFLE_VECTOR_8__(A, B, C, D, E, F, G, H) \
})
#define SHUFB8(A, B, C, D, E, F, G, H) \
((const qword){ \
SHUFFLE_VECTOR_8__(A, B, C, D, E, F, G, H) \
})
#define SHUFFLE_PATTERN_16_A__ 0x00
#define SHUFFLE_PATTERN_16_B__ 0x01
#define SHUFFLE_PATTERN_16_C__ 0x02
#define SHUFFLE_PATTERN_16_D__ 0x03
#define SHUFFLE_PATTERN_16_E__ 0x04
#define SHUFFLE_PATTERN_16_F__ 0x05
#define SHUFFLE_PATTERN_16_G__ 0x06
#define SHUFFLE_PATTERN_16_H__ 0x07
#define SHUFFLE_PATTERN_16_I__ 0x08
#define SHUFFLE_PATTERN_16_J__ 0x09
#define SHUFFLE_PATTERN_16_K__ 0x0a
#define SHUFFLE_PATTERN_16_L__ 0x0b
#define SHUFFLE_PATTERN_16_M__ 0x0c
#define SHUFFLE_PATTERN_16_N__ 0x0d
#define SHUFFLE_PATTERN_16_O__ 0x0e
#define SHUFFLE_PATTERN_16_P__ 0x0f
#define SHUFFLE_PATTERN_16_a__ 0x10
#define SHUFFLE_PATTERN_16_b__ 0x11
#define SHUFFLE_PATTERN_16_c__ 0x12
#define SHUFFLE_PATTERN_16_d__ 0x13
#define SHUFFLE_PATTERN_16_e__ 0x14
#define SHUFFLE_PATTERN_16_f__ 0x15
#define SHUFFLE_PATTERN_16_g__ 0x16
#define SHUFFLE_PATTERN_16_h__ 0x17
#define SHUFFLE_PATTERN_16_i__ 0x18
#define SHUFFLE_PATTERN_16_j__ 0x19
#define SHUFFLE_PATTERN_16_k__ 0x1a
#define SHUFFLE_PATTERN_16_l__ 0x1b
#define SHUFFLE_PATTERN_16_m__ 0x1c
#define SHUFFLE_PATTERN_16_n__ 0x1d
#define SHUFFLE_PATTERN_16_o__ 0x1e
#define SHUFFLE_PATTERN_16_p__ 0x1f
#define SHUFFLE_PATTERN_16_X__ 0xc0
#define SHUFFLE_PATTERN_16_x__ 0xc0
#define SHUFFLE_PATTERN_16_0__ 0x80
#define SHUFFLE_PATTERN_16_8__ 0xe0
#define SHUFFLE_VECTOR_16__(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P) \
SHUFFLE_PATTERN_16_##A##__, \
SHUFFLE_PATTERN_16_##B##__, \
SHUFFLE_PATTERN_16_##C##__, \
SHUFFLE_PATTERN_16_##D##__, \
SHUFFLE_PATTERN_16_##E##__, \
SHUFFLE_PATTERN_16_##F##__, \
SHUFFLE_PATTERN_16_##G##__, \
SHUFFLE_PATTERN_16_##H##__, \
SHUFFLE_PATTERN_16_##I##__, \
SHUFFLE_PATTERN_16_##J##__, \
SHUFFLE_PATTERN_16_##K##__, \
SHUFFLE_PATTERN_16_##L##__, \
SHUFFLE_PATTERN_16_##M##__, \
SHUFFLE_PATTERN_16_##N##__, \
SHUFFLE_PATTERN_16_##O##__, \
SHUFFLE_PATTERN_16_##P
#define SHUFFLE16(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P) \
((const vector unsigned char){ \
SHUFFLE_VECTOR_16__(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P) \
})
#define SHUFB16(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P) \
((const qword){ \
SHUFFLE_VECTOR_16__(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P) \
})
#endif

View file

@ -35,6 +35,7 @@
#include "util/u_math.h"
#include "spu_colorpack.h"
#include "spu_main.h"
#include "spu_shuffle.h"
#include "spu_texture.h"
#include "spu_tile.h"
#include "spu_tri.h"
@ -76,8 +77,13 @@ struct vertex_header {
* Triangle edge info
*/
struct edge {
float dx; /**< X(v1) - X(v0), used only during setup */
float dy; /**< Y(v1) - Y(v0), used only during setup */
union {
struct {
float dx; /**< X(v1) - X(v0), used only during setup */
float dy; /**< Y(v1) - Y(v0), used only during setup */
};
vec_float4 ds; /**< vector accessor for dx and dy */
};
float dxdy; /**< dx/dy */
float sx, sy; /**< first sample point coord */
int lines; /**< number of lines on this edge */
@ -102,10 +108,15 @@ struct setup_stage {
* turn. Currently fixed at 4 floats, but should change in time.
* Codegen will help cope with this.
*/
const struct vertex_header *vmax;
const struct vertex_header *vmid;
const struct vertex_header *vmin;
const struct vertex_header *vprovoke;
union {
struct {
const struct vertex_header *vmin;
const struct vertex_header *vmid;
const struct vertex_header *vmax;
const struct vertex_header *vprovoke;
};
qword vertex_headers;
};
struct edge ebot;
struct edge etop;
@ -122,8 +133,7 @@ struct setup_stage {
struct interp_coef coef[PIPE_MAX_SHADER_INPUTS];
struct {
int left[2]; /**< [0] = row0, [1] = row1 */
int right[2];
vec_int4 quad; /**< [0] = row0, [1] = row1; {left[0],left[1],right[0],right[1]} */
int y;
unsigned y_flags;
unsigned mask; /**< mask of MASK_BOTTOM/TOP_LEFT/RIGHT bits */
@ -305,27 +315,6 @@ block(int x)
}
/**
* Compute mask which indicates which pixels in the 2x2 quad are actually inside
* the triangle's bounds.
* The mask is a uint4 vector and each element will be 0 or 0xffffffff.
*/
static INLINE mask_t
calculate_mask(int x)
{
/* This is a little tricky.
* Use & instead of && to avoid branches.
* Use negation to convert true/false to ~0/0 values.
*/
mask_t mask;
mask = spu_insert(-((x >= setup.span.left[0]) & (x < setup.span.right[0])), mask, 0);
mask = spu_insert(-((x+1 >= setup.span.left[0]) & (x+1 < setup.span.right[0])), mask, 1);
mask = spu_insert(-((x >= setup.span.left[1]) & (x < setup.span.right[1])), mask, 2);
mask = spu_insert(-((x+1 >= setup.span.left[1]) & (x+1 < setup.span.right[1])), mask, 3);
return mask;
}
/**
* Render a horizontal span of quads
*/
@ -333,25 +322,29 @@ static void
flush_spans(void)
{
int minleft, maxright;
int x;
const int l0 = spu_extract(setup.span.quad, 0);
const int l1 = spu_extract(setup.span.quad, 1);
const int r0 = spu_extract(setup.span.quad, 2);
const int r1 = spu_extract(setup.span.quad, 3);
switch (setup.span.y_flags) {
case 0x3:
/* both odd and even lines written (both quad rows) */
minleft = MIN2(setup.span.left[0], setup.span.left[1]);
maxright = MAX2(setup.span.right[0], setup.span.right[1]);
minleft = MIN2(l0, l1);
maxright = MAX2(r0, r1);
break;
case 0x1:
/* only even line written (quad top row) */
minleft = setup.span.left[0];
maxright = setup.span.right[0];
minleft = l0;
maxright = r0;
break;
case 0x2:
/* only odd line written (quad bottom row) */
minleft = setup.span.left[1];
maxright = setup.span.right[1];
minleft = l1;
maxright = r1;
break;
default:
@ -389,17 +382,42 @@ flush_spans(void)
ASSERT(spu.cur_ztile_status != TILE_STATUS_DEFINED);
}
/* XXX this loop could be moved into the above switch cases and
* calculate_mask() could be simplified a bit...
*/
for (x = block(minleft); x <= block(maxright); x += 2) {
emit_quad( x, setup.span.y, calculate_mask( x ));
/* XXX this loop could be moved into the above switch cases... */
/* Setup for mask calculation */
const vec_int4 quad_LlRr = setup.span.quad;
const vec_int4 quad_RrLl = spu_rlqwbyte(quad_LlRr, 8);
const vec_int4 quad_LLll = spu_shuffle(quad_LlRr, quad_LlRr, SHUFFLE4(A,A,B,B));
const vec_int4 quad_RRrr = spu_shuffle(quad_RrLl, quad_RrLl, SHUFFLE4(A,A,B,B));
const vec_int4 twos = spu_splats(2);
const int x = block(minleft);
vec_int4 xs = {x, x+1, x, x+1};
for (; spu_extract(xs, 0) <= block(maxright); xs += twos) {
/**
* Computes mask to indicate which pixels in the 2x2 quad are actually
* inside the triangle's bounds.
*/
/* Calculate ({x,x+1,x,x+1} >= {l[0],l[0],l[1],l[1]}) */
const mask_t gt_LLll_xs = spu_cmpgt(quad_LLll, xs);
const mask_t gte_xs_LLll = spu_nand(gt_LLll_xs, gt_LLll_xs);
/* Calculate ({r[0],r[0],r[1],r[1]} > {x,x+1,x,x+1}) */
const mask_t gt_RRrr_xs = spu_cmpgt(quad_RRrr, xs);
/* Combine results to create mask */
const mask_t mask = spu_and(gte_xs_LLll, gt_RRrr_xs);
emit_quad(spu_extract(xs, 0), setup.span.y, mask);
}
setup.span.y = 0;
setup.span.y_flags = 0;
setup.span.right[0] = 0;
setup.span.right[1] = 0;
/* Zero right elements */
setup.span.quad = spu_shuffle(setup.span.quad, setup.span.quad, SHUFFLE4(A,B,0,0));
}
@ -444,55 +462,39 @@ setup_sort_vertices(const struct vertex_header *v0,
/* determine bottom to top order of vertices */
{
float y0 = spu_extract(v0->data[0], 1);
float y1 = spu_extract(v1->data[0], 1);
float y2 = spu_extract(v2->data[0], 1);
if (y0 <= y1) {
if (y1 <= y2) {
/* y0<=y1<=y2 */
setup.vmin = v0;
setup.vmid = v1;
setup.vmax = v2;
sign = -1.0f;
}
else if (y2 <= y0) {
/* y2<=y0<=y1 */
setup.vmin = v2;
setup.vmid = v0;
setup.vmax = v1;
sign = -1.0f;
}
else {
/* y0<=y2<=y1 */
setup.vmin = v0;
setup.vmid = v2;
setup.vmax = v1;
sign = 1.0f;
}
}
else {
if (y0 <= y2) {
/* y1<=y0<=y2 */
setup.vmin = v1;
setup.vmid = v0;
setup.vmax = v2;
sign = 1.0f;
}
else if (y2 <= y1) {
/* y2<=y1<=y0 */
setup.vmin = v2;
setup.vmid = v1;
setup.vmax = v0;
sign = 1.0f;
}
else {
/* y1<=y2<=y0 */
setup.vmin = v1;
setup.vmid = v2;
setup.vmax = v0;
sign = -1.0f;
}
}
/* A table of shuffle patterns for putting vertex_header pointers into
correct order. Quite magical. */
const vec_uchar16 sort_order_patterns[] = {
SHUFFLE4(A,B,C,C),
SHUFFLE4(C,A,B,C),
SHUFFLE4(A,C,B,C),
SHUFFLE4(B,C,A,C),
SHUFFLE4(B,A,C,C),
SHUFFLE4(C,B,A,C) };
/* The vertex_header pointers, packed for easy shuffling later */
const vec_uint4 vs = {(unsigned)v0, (unsigned)v1, (unsigned)v2};
/* Collate y values into two vectors for comparison.
Using only one shuffle constant! ;) */
const vec_float4 y_02_ = spu_shuffle(v0->data[0], v2->data[0], SHUFFLE4(0,B,b,C));
const vec_float4 y_10_ = spu_shuffle(v1->data[0], v0->data[0], SHUFFLE4(0,B,b,C));
const vec_float4 y_012 = spu_shuffle(y_02_, v1->data[0], SHUFFLE4(0,B,b,C));
const vec_float4 y_120 = spu_shuffle(y_10_, v2->data[0], SHUFFLE4(0,B,b,C));
/* Perform comparison: {y0,y1,y2} > {y1,y2,y0} */
const vec_uint4 compare = spu_cmpgt(y_012, y_120);
/* Compress the result of the comparison into 4 bits */
const vec_uint4 gather = spu_gather(compare);
/* Subtract one to attain the index into the LUT. Magical. */
const unsigned int index = spu_extract(gather, 0) - 1;
/* Load the appropriate pattern and construct the desired vector. */
setup.vertex_headers = (qword)spu_shuffle(vs, vs, sort_order_patterns[index]);
/* Using the result of the comparison, set sign.
Very magical. */
sign = ((si_to_uint(si_cntb((qword)gather)) == 2) ? 1.0f : -1.0f);
}
/* Check if triangle is completely outside the tile bounds */
@ -509,12 +511,9 @@ setup_sort_vertices(const struct vertex_header *v0,
spu_extract(setup.vmax->data[0], 0) > setup.cliprect_maxx)
return FALSE;
setup.ebot.dx = spu_extract(setup.vmid->data[0], 0) - spu_extract(setup.vmin->data[0], 0);
setup.ebot.dy = spu_extract(setup.vmid->data[0], 1) - spu_extract(setup.vmin->data[0], 1);
setup.emaj.dx = spu_extract(setup.vmax->data[0], 0) - spu_extract(setup.vmin->data[0], 0);
setup.emaj.dy = spu_extract(setup.vmax->data[0], 1) - spu_extract(setup.vmin->data[0], 1);
setup.etop.dx = spu_extract(setup.vmax->data[0], 0) - spu_extract(setup.vmid->data[0], 0);
setup.etop.dy = spu_extract(setup.vmax->data[0], 1) - spu_extract(setup.vmid->data[0], 1);
setup.ebot.ds = spu_sub(setup.vmid->data[0], setup.vmin->data[0]);
setup.emaj.ds = spu_sub(setup.vmax->data[0], setup.vmin->data[0]);
setup.etop.ds = spu_sub(setup.vmax->data[0], setup.vmid->data[0]);
/*
* Compute triangle's area. Use 1/area to compute partial
@ -535,8 +534,6 @@ setup_sort_vertices(const struct vertex_header *v0,
setup.facing = (area * sign > 0.0f)
^ (spu.rasterizer.front_winding == PIPE_WINDING_CW);
setup.vprovoke = v2;
return TRUE;
}
@ -746,9 +743,11 @@ subtriangle(struct edge *eleft, struct edge *eright, unsigned lines)
setup.span.y = block(_y);
}
setup.span.left[_y&1] = left;
setup.span.right[_y&1] = right;
setup.span.y_flags |= 1<<(_y&1);
int offset = _y&1;
vec_int4 quad_LlRr = {left, left, right, right};
/* Store left and right in 0 or 1 row of quad based on offset */
setup.span.quad = spu_sel(quad_LlRr, setup.span.quad, spu_maskw(5<<offset));
setup.span.y_flags |= 1<<offset;
}
}
@ -790,8 +789,8 @@ tri_draw(const float *v0, const float *v1, const float *v2,
setup.span.y = 0;
setup.span.y_flags = 0;
setup.span.right[0] = 0;
setup.span.right[1] = 0;
/* Zero right elements */
setup.span.quad = spu_shuffle(setup.span.quad, setup.span.quad, SHUFFLE4(A,B,0,0));
if (setup.oneOverArea < 0.0) {
/* emaj on left */

View file

@ -197,9 +197,7 @@ i915_vbuf_render_set_primitive( struct vbuf_render *render,
i915_render->fallback = 0;
return TRUE;
default:
assert((int)"Error unkown primtive type" & 0);
/* Actually, can handle a lot more just fine... Fixme.
*/
/* FIXME: Actually, can handle a lot more just fine... */
return FALSE;
}
}

View file

@ -50,7 +50,7 @@ nv30_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
* the existing query to notify completion, but it could be better.
*/
if (q->object) {
uint64 tmp;
uint64_t tmp;
pipe->get_query_result(pipe, pq, 1, &tmp);
}
@ -80,7 +80,7 @@ nv30_query_end(struct pipe_context *pipe, struct pipe_query *pq)
static boolean
nv30_query_result(struct pipe_context *pipe, struct pipe_query *pq,
boolean wait, uint64 *result)
boolean wait, uint64_t *result)
{
struct nv30_context *nv30 = nv30_context(pipe);
struct nv30_query *q = nv30_query(pq);

View file

@ -49,7 +49,7 @@ nv30_state_emit(struct nv30_context *nv30)
struct nv30_state *state = &nv30->state;
struct nv30_screen *screen = nv30->screen;
unsigned i, samplers;
uint64 states;
uint64_t states;
if (nv30->pctx_id != screen->cur_pctx) {
for (i = 0; i < NV30_STATE_MAX; i++) {

View file

@ -50,7 +50,7 @@ nv40_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
* the existing query to notify completion, but it could be better.
*/
if (q->object) {
uint64 tmp;
uint64_t tmp;
pipe->get_query_result(pipe, pq, 1, &tmp);
}
@ -80,7 +80,7 @@ nv40_query_end(struct pipe_context *pipe, struct pipe_query *pq)
static boolean
nv40_query_result(struct pipe_context *pipe, struct pipe_query *pq,
boolean wait, uint64 *result)
boolean wait, uint64_t *result)
{
struct nv40_context *nv40 = nv40_context(pipe);
struct nv40_query *q = nv40_query(pq);

View file

@ -65,7 +65,7 @@ nv40_state_emit(struct nv40_context *nv40)
struct nv40_state *state = &nv40->state;
struct nv40_screen *screen = nv40->screen;
unsigned i, samplers;
uint64 states;
uint64_t states;
if (nv40->pctx_id != screen->cur_pctx) {
for (i = 0; i < NV40_STATE_MAX; i++) {

View file

@ -70,6 +70,10 @@ struct nv50_rasterizer_stateobj {
struct nv50_miptree {
struct pipe_texture base;
struct pipe_buffer *buffer;
int *image_offset;
int image_nr;
int total_size;
};
static INLINE struct nv50_miptree *

View file

@ -31,7 +31,8 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
{
struct pipe_winsys *ws = pscreen->winsys;
struct nv50_miptree *mt = CALLOC_STRUCT(nv50_miptree);
unsigned usage, pitch;
unsigned usage, width = pt->width[0], height = pt->height[0];
int i;
mt->base = *pt;
mt->base.refcount = 1;
@ -47,11 +48,31 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
break;
}
pitch = ((pt->width[0] + 63) & ~63) * pt->block.size;
/*XXX*/
pitch *= 2;
switch (pt->target) {
case PIPE_TEXTURE_3D:
mt->image_nr = pt->depth[0];
break;
case PIPE_TEXTURE_CUBE:
mt->image_nr = 6;
break;
default:
mt->image_nr = 1;
break;
}
mt->image_offset = CALLOC(mt->image_nr, sizeof(int));
mt->buffer = ws->buffer_create(ws, 256, usage, pitch * pt->height[0]);
for (i = 0; i < mt->image_nr; i++) {
int image_size;
image_size = align(width, 8) * pt->block.size;
image_size = align(image_size, 64);
image_size *= align(height, 8) * pt->block.size;
mt->image_offset[i] = mt->total_size;
mt->total_size += image_size;
}
mt->buffer = ws->buffer_create(ws, 256, usage, mt->total_size);
if (!mt->buffer) {
FREE(mt);
return NULL;
@ -83,6 +104,15 @@ nv50_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
struct nv50_miptree *mt = nv50_miptree(pt);
struct nv50_surface *s;
struct pipe_surface *ps;
int img;
if (pt->target == PIPE_TEXTURE_CUBE)
img = face;
else
if (pt->target == PIPE_TEXTURE_3D)
img = zslice;
else
img = 0;
s = CALLOC_STRUCT(nv50_surface);
if (!s)
@ -98,7 +128,7 @@ nv50_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
ps->nblocksx = pt->nblocksx[level];
ps->nblocksy = pt->nblocksy[level];
ps->stride = ps->width * ps->block.size;
ps->offset = 0;
ps->offset = mt->image_offset[img];
ps->usage = flags;
ps->status = PIPE_SURFACE_STATUS_DEFINED;

View file

@ -179,6 +179,38 @@ free_temp(struct nv50_pc *pc, struct nv50_reg *r)
}
}
static int
alloc_temp4(struct nv50_pc *pc, struct nv50_reg *dst[4], int idx)
{
int i;
if ((idx + 4) >= NV50_SU_MAX_TEMP)
return 1;
if (pc->r_temp[idx] || pc->r_temp[idx + 1] ||
pc->r_temp[idx + 2] || pc->r_temp[idx + 3])
return alloc_temp4(pc, dst, idx + 1);
for (i = 0; i < 4; i++) {
dst[i] = CALLOC_STRUCT(nv50_reg);
dst[i]->type = P_TEMP;
dst[i]->index = -1;
dst[i]->hw = idx + i;
pc->r_temp[idx + i] = dst[i];
}
return 0;
}
static void
free_temp4(struct nv50_pc *pc, struct nv50_reg *reg[4])
{
int i;
for (i = 0; i < 4; i++)
free_temp(pc, reg[i]);
}
static struct nv50_reg *
temp_temp(struct nv50_pc *pc)
{
@ -902,7 +934,7 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
{
const struct tgsi_full_instruction *inst = &tok->FullInstruction;
struct nv50_reg *rdst[4], *dst[4], *src[3][4], *temp;
unsigned mask, sat;
unsigned mask, sat, unit;
int i, c;
mask = inst->FullDstRegisters[0].DstRegister.WriteMask;
@ -916,8 +948,13 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
}
for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {
struct tgsi_full_src_register *fs = &inst->FullSrcRegisters[i];
if (fs->SrcRegister.File == TGSI_FILE_SAMPLER)
unit = fs->SrcRegister.Index;
for (c = 0; c < 4; c++)
src[i][c] = tgsi_src(pc, c, &inst->FullSrcRegisters[i]);
src[i][c] = tgsi_src(pc, c, fs);
}
if (sat) {
@ -1155,35 +1192,30 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
}
break;
case TGSI_OPCODE_TEX:
{
struct nv50_reg *t0, *t1, *t2, *t3;
struct nv50_program_exec *e;
case TGSI_OPCODE_TXP:
{
struct nv50_reg *t[4];
struct nv50_program_exec *e;
t0 = alloc_temp(pc, NULL);
t0 = alloc_temp(pc, NULL);
t1 = alloc_temp(pc, NULL);
t2 = alloc_temp(pc, NULL);
t3 = alloc_temp(pc, NULL);
emit_mov(pc, t0, src[0][0]);
emit_mov(pc, t1, src[0][1]);
alloc_temp4(pc, t, 0);
emit_mov(pc, t[0], src[0][0]);
emit_mov(pc, t[1], src[0][1]);
e = exec(pc);
e->inst[0] = 0xf6400000;
set_long(pc, e);
e->inst[1] |= 0x0000c004;
set_dst(pc, t0, e);
emit(pc, e);
e = exec(pc);
e->inst[0] = 0xf6400000;
e->inst[0] |= (unit << 9);
set_long(pc, e);
e->inst[1] |= 0x0000c004;
set_dst(pc, t[0], e);
emit(pc, e);
if (mask & (1 << 0)) emit_mov(pc, dst[0], t0);
if (mask & (1 << 1)) emit_mov(pc, dst[1], t1);
if (mask & (1 << 2)) emit_mov(pc, dst[2], t2);
if (mask & (1 << 3)) emit_mov(pc, dst[3], t3);
if (mask & (1 << 0)) emit_mov(pc, dst[0], t[0]);
if (mask & (1 << 1)) emit_mov(pc, dst[1], t[1]);
if (mask & (1 << 2)) emit_mov(pc, dst[2], t[2]);
if (mask & (1 << 3)) emit_mov(pc, dst[3], t[3]);
free_temp(pc, t0);
free_temp(pc, t1);
free_temp(pc, t2);
free_temp(pc, t3);
}
free_temp4(pc, t);
}
break;
case TGSI_OPCODE_XPD:
temp = alloc_temp(pc, NULL);
@ -1570,8 +1602,13 @@ nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p)
if (!upload)
return;
NOUVEAU_ERR("-------\n");
up = ptr = MALLOC(p->exec_size * 4);
for (e = p->exec_head; e; e = e->next) {
NOUVEAU_ERR("0x%08x\n", e->inst[0]);
if (is_long(e))
NOUVEAU_ERR("0x%08x\n", e->inst[1]);
*(ptr++) = e->inst[0];
if (is_long(e))
*(ptr++) = e->inst[1];
@ -1687,7 +1724,7 @@ nv50_fragprog_validate(struct nv50_context *nv50)
void
nv50_program_destroy(struct nv50_context *nv50, struct nv50_program *p)
{
struct pipe_winsys *ws = nv50->pipe.winsys;
struct pipe_screen *pscreen = nv50->pipe.screen;
while (p->exec_head) {
struct nv50_program_exec *e = p->exec_head;
@ -1699,7 +1736,7 @@ nv50_program_destroy(struct nv50_context *nv50, struct nv50_program *p)
p->exec_size = 0;
if (p->buffer)
pipe_buffer_reference(ws, &p->buffer, NULL);
pipe_buffer_reference(pscreen, &p->buffer, NULL);
nv50->screen->nvws->res_free(&p->data);

View file

@ -51,7 +51,7 @@ nv50_query_end(struct pipe_context *pipe, struct pipe_query *q)
static boolean
nv50_query_result(struct pipe_context *pipe, struct pipe_query *q,
boolean wait, uint64 *result)
boolean wait, uint64_t *result)
{
NOUVEAU_ERR("unimplemented\n");
*result = 0xdeadcafe;

View file

@ -94,7 +94,7 @@ struct softpipe_context {
/* Counter for occlusion queries. Note this supports overlapping
* queries.
*/
uint64 occlusion_count;
uint64_t occlusion_count;
/*
* Mapped vertex buffers

View file

@ -171,7 +171,6 @@ static void shade_destroy(struct quad_stage *qs)
struct quad_stage *sp_quad_shade_stage( struct softpipe_context *softpipe )
{
struct quad_shade_stage *qss = CALLOC_STRUCT(quad_shade_stage);
uint i;
/* allocate storage for program inputs/outputs, aligned to 16 bytes */
qss->inputs = MALLOC(PIPE_MAX_ATTRIBS * sizeof(*qss->inputs) + 16);

View file

@ -37,8 +37,8 @@
#include "sp_query.h"
struct softpipe_query {
uint64 start;
uint64 end;
uint64_t start;
uint64_t end;
};
@ -87,7 +87,7 @@ static boolean
softpipe_get_query_result(struct pipe_context *pipe,
struct pipe_query *q,
boolean wait,
uint64 *result )
uint64_t *result )
{
struct softpipe_query *sq = softpipe_query(q);
*result = sq->end - sq->start;

View file

@ -55,9 +55,9 @@ softpipe_get_param(struct pipe_screen *screen, int param)
{
switch (param) {
case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
return 8;
return PIPE_MAX_SAMPLERS;
case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
return 8;
return PIPE_MAX_SAMPLERS;
case PIPE_CAP_NPOT_TEXTURES:
return 1;
case PIPE_CAP_TWO_SIDED_STENCIL:

View file

@ -94,31 +94,50 @@ softpipe_texture_layout(struct pipe_screen *screen,
return spt->buffer != NULL;
}
/* Hack it up to use the old winsys->surface_alloc_storage()
* method for now:
*/
static boolean
softpipe_displaytarget_layout(struct pipe_screen *screen,
struct softpipe_texture * spt)
{
struct pipe_winsys *ws = screen->winsys;
size_t tex_size;
unsigned cpp;
struct pipe_surface surf;
unsigned flags = (PIPE_BUFFER_USAGE_CPU_READ |
PIPE_BUFFER_USAGE_CPU_WRITE |
PIPE_BUFFER_USAGE_GPU_READ |
PIPE_BUFFER_USAGE_GPU_WRITE);
int ret;
switch (spt->base.format) {
case PIPE_FORMAT_R5G6B5_UNORM:
cpp = 2;
break;
case PIPE_FORMAT_Z24S8_UNORM:
case PIPE_FORMAT_A8R8G8B8_UNORM:
default:
cpp = 4;
break;
memset(&surf, 0, sizeof(surf));
ret =ws->surface_alloc_storage( ws,
&surf,
spt->base.width[0],
spt->base.height[0],
spt->base.format,
flags,
spt->base.tex_usage);
if(ret != 0)
return FALSE;
if (!surf.buffer) {
/* allocation failed */
return FALSE;
}
tex_size = spt->base.width[0] * cpp * spt->base.height[0];
spt->buffer = ws->buffer_create(ws, 64, PIPE_BUFFER_USAGE_PIXEL, tex_size);
/* Now extract the goodies:
*/
spt->base.nblocksx[0] = pf_get_nblocksx(&spt->base.block, spt->base.width[0]);
spt->base.nblocksy[0] = pf_get_nblocksy(&spt->base.block, spt->base.height[0]);
spt->stride[0] = spt->base.width[0] * cpp;
spt->stride[0] = surf.stride;
/* Transfer the reference:
*/
spt->buffer = surf.buffer;
surf.buffer = NULL;
return spt->buffer != NULL;
}
@ -220,10 +239,8 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
ps = CALLOC_STRUCT(pipe_surface);
ps->refcount = 1;
ps->winsys = ws;
if (ps) {
assert(ps->refcount);
assert(ps->winsys);
pipe_texture_reference(&ps->texture, pt);
pipe_buffer_reference(screen, &ps->buffer, spt->buffer);
ps->format = pt->format;

View file

@ -274,11 +274,11 @@ static INLINE boolean
trace_context_get_query_result(struct pipe_context *_pipe,
struct pipe_query *query,
boolean wait,
uint64 *presult)
uint64_t *presult)
{
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
uint64 result;
uint64_t result;
boolean _result;
trace_dump_call_begin("pipe_context", "get_query_result");

View file

@ -96,7 +96,6 @@ typedef int _Bool;
typedef unsigned int uint;
typedef unsigned char ubyte;
typedef unsigned short ushort;
typedef uint64_t uint64;
#if 0
#define boolean bool
@ -112,20 +111,22 @@ typedef unsigned char boolean;
/* Function inlining */
#ifdef __cplusplus
# define INLINE inline
#elif defined(__GNUC__)
# define INLINE __inline__
#elif defined(_MSC_VER)
# define INLINE __inline
#elif defined(__ICL)
# define INLINE __inline
#elif defined(__INTEL_COMPILER)
# define INLINE inline
#elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
# define INLINE __inline
#else
# define INLINE
#ifndef INLINE
# ifdef __cplusplus
# define INLINE inline
# elif defined(__GNUC__)
# define INLINE __inline__
# elif defined(_MSC_VER)
# define INLINE __inline
# elif defined(__ICL)
# define INLINE __inline
# elif defined(__INTEL_COMPILER)
# define INLINE inline
# elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
# define INLINE __inline
# else
# define INLINE
# endif
#endif

View file

@ -109,7 +109,7 @@ struct pipe_context {
boolean (*get_query_result)(struct pipe_context *pipe,
struct pipe_query *q,
boolean wait,
uint64 *result);
uint64_t *result);
/*@}*/
/**

View file

@ -245,7 +245,7 @@ struct st_context {
memcpy(map, vertices, size);
pipe_buffer_unmap(screen, vbuf);
util_draw_vertex_buffer(pipe, vbuf, prim, num_verts, num_attribs);
util_draw_vertex_buffer(pipe, vbuf, 0, prim, num_verts, num_attribs);
error2:
pipe_buffer_reference(screen, &vbuf, NULL);

View file

@ -19,7 +19,7 @@ if env['platform'] == 'windows':
env.Append(LIBS = [
'gdi32',
'user32',ss
'user32',
'kernel32',
])

View file

@ -320,7 +320,7 @@ gdi_softpipe_flush_frontbuffer(struct pipe_winsys *winsys,
memset(&bmi, 0, sizeof(BITMAPINFO));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = surface->stride / pf_get_size(surface->format);
bmi.bmiHeader.biHeight= -surface->height;
bmi.bmiHeader.biHeight= -(long)surface->height;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = pf_get_bits(surface->format);
bmi.bmiHeader.biCompression = BI_RGB;
@ -337,8 +337,23 @@ gdi_softpipe_flush_frontbuffer(struct pipe_winsys *winsys,
}
const struct stw_winsys stw_winsys = {
static const struct stw_winsys stw_winsys = {
&gdi_softpipe_screen_create,
&gdi_softpipe_context_create,
&gdi_softpipe_flush_frontbuffer
};
BOOL WINAPI
DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
{
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
return st_init(&stw_winsys);
case DLL_PROCESS_DETACH:
st_cleanup();
break;
}
return TRUE;
}

View file

@ -57,3 +57,62 @@
gluTessVertex
gluUnProject
gluUnProject4
mgluBeginCurve
mgluBeginPolygon
mgluBeginSurface
mgluBeginTrim
mgluBuild1DMipmapLevels
mgluBuild1DMipmaps
mgluBuild2DMipmapLevels
mgluBuild2DMipmaps
mgluBuild3DMipmapLevels
mgluBuild3DMipmaps
mgluCheckExtension
mgluCylinder
mgluDeleteNurbsRenderer
mgluDeleteQuadric
mgluDeleteTess
mgluDisk
mgluEndCurve
mgluEndPolygon
mgluEndSurface
mgluEndTrim
mgluErrorString
mgluGetNurbsProperty
mgluGetString
mgluGetTessProperty
mgluLoadSamplingMatrices
mgluLookAt
mgluNewNurbsRenderer
mgluNewQuadric
mgluNewTess
mgluNextContour
mgluNurbsCallback
mgluNurbsCallbackData
mgluNurbsCallbackDataEXT
mgluNurbsCurve
mgluNurbsProperty
mgluNurbsSurface
mgluOrtho2D
mgluPartialDisk
mgluPerspective
mgluPickMatrix
mgluProject
mgluPwlCurve
mgluQuadricCallback
mgluQuadricDrawStyle
mgluQuadricNormals
mgluQuadricOrientation
mgluQuadricTexture
mgluScaleImage
mgluSphere
mgluTessBeginContour
mgluTessBeginPolygon
mgluTessCallback
mgluTessEndContour
mgluTessEndPolygon
mgluTessNormal
mgluTessProperty
mgluTessVertex
mgluUnProject
mgluUnProject4

View file

@ -11,7 +11,6 @@ env.Replace(CPPDEFINES = [
'BUILD_GLUT32',
'GLUT_BUILDING_LIB',
'MESA',
'_DLL',
'NDEBUG',
'GLUT_NO_WARNING_DISABLE',
])
@ -38,7 +37,6 @@ sources = [
'glut_dstr.c',
'glut_event.c',
'glut_ext.c',
'glut_fcb.c',
'glut_fullscrn.c',
'glut_gamemode.c',
'glut_get.c',
@ -51,6 +49,7 @@ sources = [
'glut_mesa.c',
'glut_modifier.c',
'glut_overlay.c',
'glut_ppm.c',
'glut_shapes.c',
'glut_space.c',
'glut_stroke.c',

View file

@ -34,14 +34,10 @@ libmesa.a: $(MESA_OBJECTS)
# Make archive of gl* API dispatcher functions only
libglapi.a: $(GLAPI_OBJECTS)
@ $(MKLIB) -o glapi -static $(GLAPI_OBJECTS)
# Make archive of gl* API dispatcher functions only
$(GLAPI_LIB): $(GLAPI_OBJECTS)
@if [ "${WINDOW_SYSTEM}" = "dri" ] ; then \
touch libglapi.a ; \
else \
$(TOP)/bin/mklib -o glapi -static $(GLAPI_OBJECTS) ; \
$(MKLIB) -o glapi -static $(GLAPI_OBJECTS) ; \
fi
######################################################################

View file

@ -12,10 +12,11 @@ if env['platform'] != 'winddk':
'#/src/mesa',
])
if gcc:
env.Append(CFLAGS = [
'-std=c99',
])
if env['platform'] == 'windows':
env.Append(CPPDEFINES = [
'_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers
'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
])
#
# Source files
@ -165,6 +166,7 @@ if env['platform'] != 'winddk':
'state_tracker/st_context.c',
'state_tracker/st_debug.c',
'state_tracker/st_draw.c',
'state_tracker/st_draw_feedback.c',
'state_tracker/st_extensions.c',
'state_tracker/st_format.c',
'state_tracker/st_framebuffer.c',

View file

@ -314,10 +314,28 @@ static void driReportDamage(__DRIdrawable *pdp,
static void driSwapBuffers(__DRIdrawable *dPriv)
{
__DRIscreen *psp = dPriv->driScreenPriv;
drm_clip_rect_t *rects;
int i;
if (!dPriv->numClipRects)
return;
psp->DriverAPI.SwapBuffers(dPriv);
driReportDamage(dPriv, dPriv->pClipRects, dPriv->numClipRects);
rects = _mesa_malloc(sizeof(*rects) * dPriv->numClipRects);
if (!rects)
return;
for (i = 0; i < dPriv->numClipRects; i++) {
rects[i].x1 = dPriv->pClipRects[i].x1 - dPriv->x;
rects[i].y1 = dPriv->pClipRects[i].y1 - dPriv->y;
rects[i].x2 = dPriv->pClipRects[i].x2 - dPriv->x;
rects[i].y2 = dPriv->pClipRects[i].y2 - dPriv->y;
}
driReportDamage(dPriv, rects, dPriv->numClipRects);
_mesa_free(rects);
}
static int driDrawableGetMSC( __DRIscreen *sPriv, __DRIdrawable *dPriv,

View file

@ -130,9 +130,8 @@ int driWaitForMSC32( __DRIdrawablePrivate *priv,
if ( divisor != 0 ) {
unsigned int target = (unsigned int)target_msc;
unsigned int next = target;
unsigned int r;
int64_t next = target_msc;
int64_t r;
int dont_wait = (target_msc == 0);
do {
@ -154,9 +153,9 @@ int driWaitForMSC32( __DRIdrawablePrivate *priv,
*msc = vblank_to_msc(priv, vbl.reply.sequence);
dont_wait = 0;
if (target_msc != 0 && *msc == target)
if (!dont_wait && *msc == next)
break;
dont_wait = 0;
/* Assuming the wait-done test fails, the next refresh to wait for
* will be one that satisfies (MSC % divisor) == remainder. The
@ -165,11 +164,12 @@ int driWaitForMSC32( __DRIdrawablePrivate *priv,
* If this refresh has already happened, we add divisor to obtain
* the next refresh after the current one that will satisfy it.
*/
r = (*msc % (unsigned int)divisor);
next = (*msc - r + (unsigned int)remainder);
if (next <= *msc) next += (unsigned int)divisor;
r = ((uint64_t)*msc % divisor);
next = (*msc - r + remainder);
if (next <= *msc)
next += divisor;
} while ( r != (unsigned int)remainder );
} while (r != remainder);
}
else {
/* If the \c divisor is zero, just wait until the MSC is greater

View file

@ -55,6 +55,7 @@ static const struct dri_extension i915_extensions[] = {
{"GL_ARB_fragment_program", NULL},
{"GL_ARB_shadow", NULL},
{"GL_ARB_texture_non_power_of_two", NULL},
{"GL_ATI_texture_env_combine3", NULL},
{"GL_EXT_shadow_funcs", NULL},
{NULL, NULL}
};

View file

@ -1105,30 +1105,14 @@ i915ValidateFragmentProgram(struct i915_context *i915)
EMIT_ATTR(_TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, S4_VFMT_COLOR, 4);
}
if ((inputsRead & (FRAG_BIT_COL1 | FRAG_BIT_FOGC)) ||
i915->vertex_fog != I915_FOG_NONE) {
if (inputsRead & FRAG_BIT_COL1) {
intel->specoffset = offset / 4;
EMIT_ATTR(_TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, S4_VFMT_SPEC_FOG, 3);
}
else
EMIT_PAD(3);
if ((inputsRead & FRAG_BIT_FOGC) || i915->vertex_fog != I915_FOG_NONE)
EMIT_ATTR(_TNL_ATTRIB_FOG, EMIT_1UB_1F, S4_VFMT_SPEC_FOG, 1);
else
EMIT_PAD(1);
if (inputsRead & FRAG_BIT_COL1) {
intel->specoffset = offset / 4;
EMIT_ATTR(_TNL_ATTRIB_COLOR1, EMIT_4UB_4F_BGRA, S4_VFMT_SPEC_FOG, 4);
}
/* XXX this was disabled, but enabling this code helped fix the Glean
* tfragprog1 fog tests.
*/
#if 1
if ((inputsRead & FRAG_BIT_FOGC) || i915->vertex_fog != I915_FOG_NONE) {
EMIT_ATTR(_TNL_ATTRIB_FOG, EMIT_1F, S4_VFMT_FOG_PARAM, 4);
}
#endif
for (i = 0; i < p->ctx->Const.MaxTextureCoordUnits; i++) {
if (inputsRead & FRAG_BIT_TEX(i)) {

View file

@ -32,6 +32,7 @@
#include "main/imports.h"
#include "main/api_noop.h"
#include "main/macros.h"
#include "main/vtxfmt.h"
#include "main/simple_list.h"
#include "shader/shader_api.h"
@ -128,9 +129,10 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis,
TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline;
ctx->Const.MaxTextureUnits = BRW_MAX_TEX_UNIT;
ctx->Const.MaxTextureImageUnits = BRW_MAX_TEX_UNIT;
ctx->Const.MaxTextureCoordUnits = BRW_MAX_TEX_UNIT;
ctx->Const.MaxTextureCoordUnits = 8; /* Mesa limit */
ctx->Const.MaxTextureUnits = MIN2(ctx->Const.MaxTextureCoordUnits,
ctx->Const.MaxTextureImageUnits);
ctx->Const.MaxVertexTextureImageUnits = 0; /* no vertex shader textures */
/* Advertise the full hardware capabilities. The new memory

View file

@ -238,7 +238,7 @@ struct brw_vs_ouput_sizes {
};
#define BRW_MAX_TEX_UNIT 8
#define BRW_MAX_TEX_UNIT 16
#define BRW_WM_MAX_SURF BRW_MAX_TEX_UNIT + MAX_DRAW_BUFFERS
enum brw_cache_id {

View file

@ -129,17 +129,28 @@ static INLINE int type_sz( GLuint type )
}
}
/**
* Construct a brw_reg.
* \param file one of the BRW_x_REGISTER_FILE values
* \param nr register number/index
* \param subnr register sub number
* \param type one of BRW_REGISTER_TYPE_x
* \param vstride one of BRW_VERTICAL_STRIDE_x
* \param width one of BRW_WIDTH_x
* \param hstride one of BRW_HORIZONTAL_STRIDE_x
* \param swizzle one of BRW_SWIZZLE_x
* \param writemask WRITEMASK_X/Y/Z/W bitfield
*/
static INLINE struct brw_reg brw_reg( GLuint file,
GLuint nr,
GLuint subnr,
GLuint type,
GLuint vstride,
GLuint width,
GLuint hstride,
GLuint swizzle,
GLuint writemask)
GLuint nr,
GLuint subnr,
GLuint type,
GLuint vstride,
GLuint width,
GLuint hstride,
GLuint swizzle,
GLuint writemask )
{
struct brw_reg reg;
reg.type = type;
reg.file = file;
@ -166,6 +177,7 @@ static INLINE struct brw_reg brw_reg( GLuint file,
return reg;
}
/** Construct float[16] register */
static INLINE struct brw_reg brw_vec16_reg( GLuint file,
GLuint nr,
GLuint subnr )
@ -181,6 +193,7 @@ static INLINE struct brw_reg brw_vec16_reg( GLuint file,
WRITEMASK_XYZW);
}
/** Construct float[8] register */
static INLINE struct brw_reg brw_vec8_reg( GLuint file,
GLuint nr,
GLuint subnr )
@ -196,7 +209,7 @@ static INLINE struct brw_reg brw_vec8_reg( GLuint file,
WRITEMASK_XYZW);
}
/** Construct float[4] register */
static INLINE struct brw_reg brw_vec4_reg( GLuint file,
GLuint nr,
GLuint subnr )
@ -212,7 +225,7 @@ static INLINE struct brw_reg brw_vec4_reg( GLuint file,
WRITEMASK_XYZW);
}
/** Construct float[2] register */
static INLINE struct brw_reg brw_vec2_reg( GLuint file,
GLuint nr,
GLuint subnr )
@ -228,6 +241,7 @@ static INLINE struct brw_reg brw_vec2_reg( GLuint file,
WRITEMASK_XY);
}
/** Construct float[1] register */
static INLINE struct brw_reg brw_vec1_reg( GLuint file,
GLuint nr,
GLuint subnr )
@ -277,6 +291,7 @@ static INLINE struct brw_reg byte_offset( struct brw_reg reg,
}
/** Construct unsigned word[16] register */
static INLINE struct brw_reg brw_uw16_reg( GLuint file,
GLuint nr,
GLuint subnr )
@ -284,6 +299,7 @@ static INLINE struct brw_reg brw_uw16_reg( GLuint file,
return suboffset(retype(brw_vec16_reg(file, nr, 0), BRW_REGISTER_TYPE_UW), subnr);
}
/** Construct unsigned word[8] register */
static INLINE struct brw_reg brw_uw8_reg( GLuint file,
GLuint nr,
GLuint subnr )
@ -291,6 +307,7 @@ static INLINE struct brw_reg brw_uw8_reg( GLuint file,
return suboffset(retype(brw_vec8_reg(file, nr, 0), BRW_REGISTER_TYPE_UW), subnr);
}
/** Construct unsigned word[1] register */
static INLINE struct brw_reg brw_uw1_reg( GLuint file,
GLuint nr,
GLuint subnr )
@ -311,6 +328,7 @@ static INLINE struct brw_reg brw_imm_reg( GLuint type )
0);
}
/** Construct float immediate register */
static INLINE struct brw_reg brw_imm_f( GLfloat f )
{
struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_F);
@ -318,6 +336,7 @@ static INLINE struct brw_reg brw_imm_f( GLfloat f )
return imm;
}
/** Construct integer immediate register */
static INLINE struct brw_reg brw_imm_d( GLint d )
{
struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_D);
@ -325,6 +344,7 @@ static INLINE struct brw_reg brw_imm_d( GLint d )
return imm;
}
/** Construct uint immediate register */
static INLINE struct brw_reg brw_imm_ud( GLuint ud )
{
struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_UD);
@ -332,6 +352,7 @@ static INLINE struct brw_reg brw_imm_ud( GLuint ud )
return imm;
}
/** Construct ushort immediate register */
static INLINE struct brw_reg brw_imm_uw( GLushort uw )
{
struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_UW);
@ -339,6 +360,7 @@ static INLINE struct brw_reg brw_imm_uw( GLushort uw )
return imm;
}
/** Construct short immediate register */
static INLINE struct brw_reg brw_imm_w( GLshort w )
{
struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_W);
@ -350,8 +372,7 @@ static INLINE struct brw_reg brw_imm_w( GLshort w )
* numbers alias with _V and _VF below:
*/
/* Vector of eight signed half-byte values:
*/
/** Construct vector of eight signed half-byte values */
static INLINE struct brw_reg brw_imm_v( GLuint v )
{
struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_V);
@ -362,8 +383,7 @@ static INLINE struct brw_reg brw_imm_v( GLuint v )
return imm;
}
/* Vector of four 8-bit float values:
*/
/** Construct vector of four 8-bit float values */
static INLINE struct brw_reg brw_imm_vf( GLuint v )
{
struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_VF);
@ -400,44 +420,43 @@ static INLINE struct brw_reg brw_address( struct brw_reg reg )
return brw_imm_uw(reg.nr * REG_SIZE + reg.subnr);
}
static INLINE struct brw_reg brw_vec1_grf( GLuint nr,
GLuint subnr )
/** Construct float[1] general-purpose register */
static INLINE struct brw_reg brw_vec1_grf( GLuint nr, GLuint subnr )
{
return brw_vec1_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
}
static INLINE struct brw_reg brw_vec8_grf( GLuint nr,
GLuint subnr )
{
return brw_vec8_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
}
static INLINE struct brw_reg brw_vec4_grf( GLuint nr,
GLuint subnr )
{
return brw_vec4_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
}
static INLINE struct brw_reg brw_vec2_grf( GLuint nr,
GLuint subnr )
/** Construct float[2] general-purpose register */
static INLINE struct brw_reg brw_vec2_grf( GLuint nr, GLuint subnr )
{
return brw_vec2_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
}
static INLINE struct brw_reg brw_uw8_grf( GLuint nr,
GLuint subnr )
/** Construct float[4] general-purpose register */
static INLINE struct brw_reg brw_vec4_grf( GLuint nr, GLuint subnr )
{
return brw_vec4_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
}
/** Construct float[8] general-purpose register */
static INLINE struct brw_reg brw_vec8_grf( GLuint nr, GLuint subnr )
{
return brw_vec8_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
}
static INLINE struct brw_reg brw_uw8_grf( GLuint nr, GLuint subnr )
{
return brw_uw8_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
}
static INLINE struct brw_reg brw_uw16_grf( GLuint nr,
GLuint subnr )
static INLINE struct brw_reg brw_uw16_grf( GLuint nr, GLuint subnr )
{
return brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
}
/** Construct null register (usually used for setting condition codes) */
static INLINE struct brw_reg brw_null_reg( void )
{
return brw_vec8_reg(BRW_ARCHITECTURE_REGISTER_FILE,
@ -524,13 +543,13 @@ static INLINE struct brw_reg stride( struct brw_reg reg,
GLuint width,
GLuint hstride )
{
reg.vstride = cvt(vstride);
reg.width = cvt(width) - 1;
reg.hstride = cvt(hstride);
return reg;
}
static INLINE struct brw_reg vec16( struct brw_reg reg )
{
return stride(reg, 16,16,1);
@ -556,6 +575,7 @@ static INLINE struct brw_reg vec1( struct brw_reg reg )
return stride(reg, 0,1,0);
}
static INLINE struct brw_reg get_element( struct brw_reg reg, GLuint elt )
{
return vec1(suboffset(reg, elt));
@ -687,7 +707,7 @@ static INLINE struct brw_indirect brw_indirect( GLuint addr_subnr, GLint offset
static INLINE struct brw_instruction *current_insn( struct brw_compile *p)
{
return &p->store[p->nr_insn];
return &p->store[p->nr_insn];
}
void brw_pop_insn_state( struct brw_compile *p );
@ -733,6 +753,7 @@ ALU2(ADD)
ALU2(MUL)
ALU1(FRC)
ALU1(RNDD)
ALU1(RNDZ)
ALU2(MAC)
ALU2(MACH)
ALU1(LZD)

View file

@ -439,6 +439,7 @@ ALU2(ADD)
ALU2(MUL)
ALU1(FRC)
ALU1(RNDD)
ALU1(RNDZ)
ALU2(MAC)
ALU2(MACH)
ALU1(LZD)

View file

@ -73,8 +73,6 @@ static void brw_vs_alloc_regs( struct brw_vs_compile *c )
c->prog_data.curb_read_length = reg - 1;
/* Allocate input regs:
*/
c->nr_inputs = 0;
@ -84,8 +82,7 @@ static void brw_vs_alloc_regs( struct brw_vs_compile *c )
c->regs[PROGRAM_INPUT][i] = brw_vec8_grf(reg, 0);
reg++;
}
}
}
/* Allocate outputs: TODO: could organize the non-position outputs
* to go straight into message regs.
@ -339,6 +336,7 @@ static void emit_math1( struct brw_vs_compile *c,
}
}
static void emit_math2( struct brw_vs_compile *c,
GLuint function,
struct brw_reg dst,
@ -370,7 +368,6 @@ static void emit_math2( struct brw_vs_compile *c,
release_tmp(c, tmp);
}
}
static void emit_exp_noalias( struct brw_vs_compile *c,
@ -521,8 +518,6 @@ static void emit_log_noalias( struct brw_vs_compile *c,
}
/* Need to unalias - consider swizzles: r0 = DST r0.xxxx r1
*/
static void emit_dst_noalias( struct brw_vs_compile *c,
@ -544,6 +539,7 @@ static void emit_dst_noalias( struct brw_vs_compile *c,
brw_MOV(p, brw_writemask(dst, WRITEMASK_W), arg1);
}
static void emit_xpd( struct brw_compile *p,
struct brw_reg dst,
struct brw_reg t,
@ -554,7 +550,6 @@ static void emit_xpd( struct brw_compile *p,
}
static void emit_lit_noalias( struct brw_vs_compile *c,
struct brw_reg dst,
struct brw_reg arg0 )
@ -596,7 +591,29 @@ static void emit_lit_noalias( struct brw_vs_compile *c,
}
/** 3 or 4-component vector normalization */
static void emit_nrm( struct brw_vs_compile *c,
struct brw_reg dst,
struct brw_reg arg0,
int num_comps)
{
struct brw_compile *p = &c->func;
struct brw_reg tmp = get_tmp(c);
/* tmp = dot(arg0, arg0) */
if (num_comps == 3)
brw_DP3(p, tmp, arg0, arg0);
else
brw_DP4(p, tmp, arg0, arg0);
/* tmp = 1 / sqrt(tmp) */
emit_math1(c, BRW_MATH_FUNCTION_RSQ, tmp, tmp, BRW_MATH_PRECISION_FULL);
/* dst = arg0 * tmp */
brw_MUL(p, dst, arg0, tmp);
release_tmp(c, tmp);
}
/* TODO: relative addressing!
@ -634,7 +651,6 @@ static struct brw_reg get_reg( struct brw_vs_compile *c,
}
static struct brw_reg deref( struct brw_vs_compile *c,
struct brw_reg arg,
GLint offset)
@ -728,8 +744,6 @@ static struct brw_reg get_dst( struct brw_vs_compile *c,
}
static void emit_swz( struct brw_vs_compile *c,
struct brw_reg dst,
struct prog_src_register src )
@ -801,8 +815,8 @@ static void emit_swz( struct brw_vs_compile *c,
}
/* Post-vertex-program processing. Send the results to the URB.
/**
* Post-vertex-program processing. Send the results to the URB.
*/
static void emit_vertex_write( struct brw_vs_compile *c)
{
@ -817,7 +831,6 @@ static void emit_vertex_write( struct brw_vs_compile *c)
get_reg(c, PROGRAM_INPUT, VERT_ATTRIB_EDGEFLAG));
}
/* Build ndc coords */
if (!c->key.know_w_is_one) {
ndc = get_tmp(c);
@ -848,7 +861,6 @@ static void emit_vertex_write( struct brw_vs_compile *c)
brw_AND(p, brw_writemask(header1, WRITEMASK_W), header1, brw_imm_ud(0x7ff<<8));
}
for (i = 0; i < c->key.nr_userclip; i++) {
brw_set_conditionalmod(p, BRW_CONDITIONAL_L);
brw_DP4(p, brw_null_reg(), pos, c->userplane[i]);
@ -856,7 +868,6 @@ static void emit_vertex_write( struct brw_vs_compile *c)
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
}
/* i965 clipping workaround:
* 1) Test for -ve rhw
* 2) If set,
@ -888,14 +899,12 @@ static void emit_vertex_write( struct brw_vs_compile *c)
brw_MOV(p, retype(brw_message_reg(1), BRW_REGISTER_TYPE_UD), brw_imm_ud(0));
}
/* Emit the (interleaved) headers for the two vertices - an 8-reg
* of zeros followed by two sets of NDC coordinates:
*/
brw_set_access_mode(p, BRW_ALIGN_1);
brw_MOV(p, offset(m0, 2), ndc);
brw_MOV(p, offset(m0, 3), pos);
brw_urb_WRITE(p,
brw_null_reg(), /* dest */
@ -909,9 +918,9 @@ static void emit_vertex_write( struct brw_vs_compile *c)
1, /* writes complete */
0, /* urb destination offset */
BRW_URB_SWIZZLE_INTERLEAVE);
}
static void
post_vs_emit( struct brw_vs_compile *c, struct brw_instruction *end_inst )
{
@ -1035,6 +1044,12 @@ void brw_vs_emit(struct brw_vs_compile *c )
case OPCODE_DPH:
brw_DPH(p, dst, args[0], args[1]);
break;
case OPCODE_NRM3:
emit_nrm(c, dst, args[0], 3);
break;
case OPCODE_NRM4:
emit_nrm(c, dst, args[0], 4);
break;
case OPCODE_DST:
unalias2(c, dst, args[0], args[1], emit_dst_noalias);
break;
@ -1102,7 +1117,7 @@ void brw_vs_emit(struct brw_vs_compile *c )
break;
case OPCODE_SGT:
emit_sgt(p, dst, args[0], args[1]);
break;
break;
case OPCODE_SLT:
emit_slt(p, dst, args[0], args[1]);
break;
@ -1118,6 +1133,10 @@ void brw_vs_emit(struct brw_vs_compile *c )
*/
emit_swz(c, dst, inst->SrcReg[0] );
break;
case OPCODE_TRUNC:
/* round toward zero */
brw_RNDZ(p, dst, args[0]);
break;
case OPCODE_XPD:
emit_xpd(p, dst, args[0], args[1]);
break;
@ -1136,7 +1155,7 @@ void brw_vs_emit(struct brw_vs_compile *c )
brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
brw_ADD(p, brw_ip_reg(), brw_ip_reg(), brw_imm_d(1*16));
brw_set_predicate_control_flag_value(p, 0xff);
break;
break;
case OPCODE_CAL:
brw_set_access_mode(p, BRW_ALIGN_1);
brw_ADD(p, deref_1d(stack_index, 0), brw_ip_reg(), brw_imm_d(3*16));
@ -1145,7 +1164,7 @@ void brw_vs_emit(struct brw_vs_compile *c )
get_addr_reg(stack_index), brw_imm_d(4));
inst->Data = &p->store[p->nr_insn];
brw_ADD(p, brw_ip_reg(), brw_ip_reg(), brw_imm_d(1*16));
break;
break;
case OPCODE_RET:
brw_ADD(p, get_addr_reg(stack_index),
get_addr_reg(stack_index), brw_imm_d(-4));
@ -1154,17 +1173,17 @@ void brw_vs_emit(struct brw_vs_compile *c )
brw_set_access_mode(p, BRW_ALIGN_16);
case OPCODE_END:
brw_ADD(p, brw_ip_reg(), brw_ip_reg(), brw_imm_d(1*16));
break;
break;
case OPCODE_PRINT:
case OPCODE_BGNSUB:
case OPCODE_ENDSUB:
/* no-op instructions */
break;
default:
_mesa_printf("Unsupported opcode %i (%s) in vertex shader\n",
inst->Opcode, inst->Opcode < MAX_OPCODE ?
_mesa_problem(NULL, "Unsupported opcode %i (%s) in vertex shader",
inst->Opcode, inst->Opcode < MAX_OPCODE ?
_mesa_opcode_string(inst->Opcode) :
"unknown");
break;
}
if ((inst->DstReg.File == PROGRAM_OUTPUT)

View file

@ -36,6 +36,7 @@
#include "brw_state.h"
/** Return number of src args for given instruction */
GLuint brw_wm_nr_args( GLuint opcode )
{
switch (opcode) {
@ -58,6 +59,8 @@ GLuint brw_wm_nr_args( GLuint opcode )
case OPCODE_TXP:
case OPCODE_KIL:
case OPCODE_LIT:
case OPCODE_NRM3:
case OPCODE_NRM4:
case WM_CINTERP:
case WM_WPOSXY:
return 1;

View file

@ -194,7 +194,7 @@ static void emit_linterp( struct brw_compile *p,
interp[2] = brw_vec1_grf(nr+1, 0);
interp[3] = brw_vec1_grf(nr+1, 4);
for(i = 0; i < 4; i++ ) {
for (i = 0; i < 4; i++) {
if (mask & (1<<i)) {
brw_LINE(p, brw_null_reg(), interp[i], deltas[0]);
brw_MAC(p, dst[i], suboffset(interp[i],1), deltas[1]);
@ -219,44 +219,42 @@ static void emit_pinterp( struct brw_compile *p,
interp[2] = brw_vec1_grf(nr+1, 0);
interp[3] = brw_vec1_grf(nr+1, 4);
for(i = 0; i < 4; i++ ) {
for (i = 0; i < 4; i++) {
if (mask & (1<<i)) {
brw_LINE(p, brw_null_reg(), interp[i], deltas[0]);
brw_MAC(p, dst[i], suboffset(interp[i],1), deltas[1]);
}
}
for(i = 0; i < 4; i++ ) {
for (i = 0; i < 4; i++) {
if (mask & (1<<i)) {
brw_MUL(p, dst[i], dst[i], w[3]);
}
}
}
static void emit_cinterp( struct brw_compile *p,
const struct brw_reg *dst,
GLuint mask,
const struct brw_reg *arg0 )
{
struct brw_reg interp[4];
GLuint nr = arg0[0].nr;
GLuint i;
struct brw_reg interp[4];
GLuint nr = arg0[0].nr;
GLuint i;
interp[0] = brw_vec1_grf(nr, 0);
interp[1] = brw_vec1_grf(nr, 4);
interp[2] = brw_vec1_grf(nr+1, 0);
interp[3] = brw_vec1_grf(nr+1, 4);
interp[0] = brw_vec1_grf(nr, 0);
interp[1] = brw_vec1_grf(nr, 4);
interp[2] = brw_vec1_grf(nr+1, 0);
interp[3] = brw_vec1_grf(nr+1, 4);
for(i = 0; i < 4; i++ ) {
if (mask & (1<<i)) {
brw_MOV(p, dst[i], suboffset(interp[i],3)); /* TODO: optimize away like other moves */
}
}
for (i = 0; i < 4; i++) {
if (mask & (1<<i)) {
brw_MOV(p, dst[i], suboffset(interp[i],3)); /* TODO: optimize away like other moves */
}
}
}
static void emit_alu1( struct brw_compile *p,
struct brw_instruction *(*func)(struct brw_compile *,
struct brw_reg,
@ -280,6 +278,7 @@ static void emit_alu1( struct brw_compile *p,
brw_set_saturate(p, 0);
}
static void emit_alu2( struct brw_compile *p,
struct brw_instruction *(*func)(struct brw_compile *,
struct brw_reg,
@ -351,6 +350,7 @@ static void emit_lrp( struct brw_compile *p,
}
}
}
static void emit_sop( struct brw_compile *p,
const struct brw_reg *dst,
GLuint mask,
@ -376,7 +376,7 @@ static void emit_slt( struct brw_compile *p,
const struct brw_reg *arg0,
const struct brw_reg *arg1 )
{
emit_sop(p, dst, mask, BRW_CONDITIONAL_L, arg0, arg1);
emit_sop(p, dst, mask, BRW_CONDITIONAL_L, arg0, arg1);
}
static void emit_sle( struct brw_compile *p,
@ -385,7 +385,7 @@ static void emit_sle( struct brw_compile *p,
const struct brw_reg *arg0,
const struct brw_reg *arg1 )
{
emit_sop(p, dst, mask, BRW_CONDITIONAL_LE, arg0, arg1);
emit_sop(p, dst, mask, BRW_CONDITIONAL_LE, arg0, arg1);
}
static void emit_sgt( struct brw_compile *p,
@ -394,7 +394,7 @@ static void emit_sgt( struct brw_compile *p,
const struct brw_reg *arg0,
const struct brw_reg *arg1 )
{
emit_sop(p, dst, mask, BRW_CONDITIONAL_G, arg0, arg1);
emit_sop(p, dst, mask, BRW_CONDITIONAL_G, arg0, arg1);
}
static void emit_sge( struct brw_compile *p,
@ -403,7 +403,7 @@ static void emit_sge( struct brw_compile *p,
const struct brw_reg *arg0,
const struct brw_reg *arg1 )
{
emit_sop(p, dst, mask, BRW_CONDITIONAL_GE, arg0, arg1);
emit_sop(p, dst, mask, BRW_CONDITIONAL_GE, arg0, arg1);
}
static void emit_seq( struct brw_compile *p,
@ -412,7 +412,7 @@ static void emit_seq( struct brw_compile *p,
const struct brw_reg *arg0,
const struct brw_reg *arg1 )
{
emit_sop(p, dst, mask, BRW_CONDITIONAL_EQ, arg0, arg1);
emit_sop(p, dst, mask, BRW_CONDITIONAL_EQ, arg0, arg1);
}
static void emit_sne( struct brw_compile *p,
@ -421,7 +421,7 @@ static void emit_sne( struct brw_compile *p,
const struct brw_reg *arg0,
const struct brw_reg *arg1 )
{
emit_sop(p, dst, mask, BRW_CONDITIONAL_NEQ, arg0, arg1);
emit_sop(p, dst, mask, BRW_CONDITIONAL_NEQ, arg0, arg1);
}
static void emit_cmp( struct brw_compile *p,
@ -505,7 +505,7 @@ static void emit_dp3( struct brw_compile *p,
const struct brw_reg *arg1 )
{
if (!(mask & WRITEMASK_XYZW))
return; /* Do not emit dead code*/
return; /* Do not emit dead code */
assert((mask & WRITEMASK_XYZW) == WRITEMASK_X);
@ -525,7 +525,7 @@ static void emit_dp4( struct brw_compile *p,
const struct brw_reg *arg1 )
{
if (!(mask & WRITEMASK_XYZW))
return; /* Do not emit dead code*/
return; /* Do not emit dead code */
assert((mask & WRITEMASK_XYZW) == WRITEMASK_X);
@ -546,7 +546,7 @@ static void emit_dph( struct brw_compile *p,
const struct brw_reg *arg1 )
{
if (!(mask & WRITEMASK_XYZW))
return; /* Do not emit dead code*/
return; /* Do not emit dead code */
assert((mask & WRITEMASK_XYZW) == WRITEMASK_X);
@ -592,7 +592,7 @@ static void emit_math1( struct brw_compile *p,
const struct brw_reg *arg0 )
{
if (!(mask & WRITEMASK_XYZW))
return; /* Do not emit dead code*/
return; /* Do not emit dead code */
//assert((mask & WRITEMASK_XYZW) == WRITEMASK_X ||
// function == BRW_MATH_FUNCTION_SINCOS);
@ -619,7 +619,7 @@ static void emit_math2( struct brw_compile *p,
const struct brw_reg *arg1)
{
if (!(mask & WRITEMASK_XYZW))
return; /* Do not emit dead code*/
return; /* Do not emit dead code */
assert((mask & WRITEMASK_XYZW) == WRITEMASK_X);
@ -760,7 +760,6 @@ static void emit_txb( struct brw_wm_compile *c,
brw_MOV(p, brw_message_reg(8), arg[3]);
msgLength = 9;
brw_SAMPLE(p,
retype(vec16(dst[0]), BRW_REGISTER_TYPE_UW),
1,
@ -772,7 +771,6 @@ static void emit_txb( struct brw_wm_compile *c,
8, /* responseLength */
msgLength,
0);
}
@ -823,7 +821,6 @@ static void emit_kil( struct brw_wm_compile *c,
struct brw_reg r0uw = retype(brw_vec1_grf(0, 0), BRW_REGISTER_TYPE_UW);
GLuint i;
/* XXX - usually won't need 4 compares!
*/
for (i = 0; i < 4; i++) {
@ -836,6 +833,7 @@ static void emit_kil( struct brw_wm_compile *c,
}
}
static void fire_fb_write( struct brw_wm_compile *c,
GLuint base_reg,
GLuint nr,
@ -869,6 +867,7 @@ static void fire_fb_write( struct brw_wm_compile *c,
eot);
}
static void emit_aa( struct brw_wm_compile *c,
struct brw_reg *arg1,
GLuint reg )
@ -962,7 +961,6 @@ static void emit_fb_write( struct brw_wm_compile *c,
nr += 2;
}
if (!c->key.runtime_check_aads_emit) {
if (c->key.aa_dest_stencil_reg)
emit_aa(c, arg1, 2);
@ -996,8 +994,6 @@ static void emit_fb_write( struct brw_wm_compile *c,
}
/* Post-fragment-program processing. Send the results to the
* framebuffer.
*/
@ -1022,6 +1018,7 @@ static void emit_spill( struct brw_wm_compile *c,
slot);
}
static void emit_unspill( struct brw_wm_compile *c,
struct brw_reg reg,
GLuint slot )
@ -1047,7 +1044,6 @@ static void emit_unspill( struct brw_wm_compile *c,
}
/**
* Retrieve upto 4 GEN4 register pairs for the given wm reg:
*/
@ -1073,6 +1069,7 @@ static void get_argument_regs( struct brw_wm_compile *c,
}
}
static void spill_values( struct brw_wm_compile *c,
struct brw_wm_value *values,
GLuint nr )
@ -1085,7 +1082,6 @@ static void spill_values( struct brw_wm_compile *c,
}
/* Emit the fragment program instructions here.
*/
void brw_wm_emit( struct brw_wm_compile *c )
@ -1176,7 +1172,7 @@ void brw_wm_emit( struct brw_wm_compile *c )
emit_alu1(p, brw_RNDD, dst, dst_flags, args[0]);
break;
case OPCODE_DP3: /* */
case OPCODE_DP3:
emit_dp3(p, dst, dst_flags, args[0], args[1]);
break;
@ -1188,7 +1184,7 @@ void brw_wm_emit( struct brw_wm_compile *c )
emit_dph(p, dst, dst_flags, args[0], args[1]);
break;
case OPCODE_LRP: /* */
case OPCODE_LRP:
emit_lrp(p, dst, dst_flags, args[0], args[1], args[2]);
break;
@ -1315,8 +1311,3 @@ void brw_wm_emit( struct brw_wm_compile *c )
inst->dst[i]->spill_slot);
}
}

View file

@ -267,7 +267,7 @@ static void emit_trunc( struct brw_wm_compile *c,
struct brw_reg src, dst;
dst = get_dst_reg(c, inst, i, 1) ;
src = get_src_reg(c, &inst->SrcReg[0], i, 1);
brw_RNDD(p, dst, src);
brw_RNDZ(p, dst, src);
}
}
brw_set_saturate(p, 0);

View file

@ -181,7 +181,7 @@ intelUpdatePageFlipping(struct intel_context *intel,
intel_fb->pf_current_page = (intel->sarea->pf_current_page >>
(intel_fb->pf_planes & 0x2)) & 0x3;
intel_fb->pf_num_pages = intel->intelScreen->third.handle ? 3 : 2;
intel_fb->pf_num_pages = 2;
pf_active = pf_planes && (pf_planes & intel->sarea->pf_active) == pf_planes;

View file

@ -412,6 +412,7 @@ static const struct dri_extension brw_extensions[] = {
{ "GL_EXT_shadow_funcs", NULL },
{ "GL_EXT_texture_sRGB", NULL },
{ "GL_ATI_separate_stencil", GL_ATI_separate_stencil_functions },
{ "GL_ATI_texture_env_combine3", NULL },
{ NULL, NULL }
};
@ -775,7 +776,6 @@ intelDestroyContext(__DRIcontextPrivate * driContextPriv)
intel_region_release(&intel->front_region);
intel_region_release(&intel->back_region);
intel_region_release(&intel->third_region);
intel_region_release(&intel->depth_region);
driDestroyOptionCache(&intel->optionCache);
@ -825,12 +825,7 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
intel_renderbuffer_set_region(intel_fb->color_rb[1],
intel->back_region);
}
#if 0
if (intel_fb->color_rb[2]) {
intel_renderbuffer_set_region(intel_fb->color_rb[2],
intel->third_region);
}
#endif
if (irbDepth) {
intel_renderbuffer_set_region(irbDepth, intel->depth_region);
}
@ -867,7 +862,7 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
driDrawableInitVBlank(driDrawPriv);
intel_fb->vbl_waited = driDrawPriv->vblSeq;
for (i = 0; i < (intel->intelScreen->third.handle ? 3 : 2); i++) {
for (i = 0; i < 2; i++) {
if (intel_fb->color_rb[i])
intel_fb->color_rb[i]->vbl_pending = driDrawPriv->vblSeq;
}

View file

@ -157,6 +157,19 @@ struct intel_context
void (*debug_batch)(struct intel_context *intel);
} vtbl;
struct {
struct gl_fragment_program *bitmap_fp;
struct gl_vertex_program *passthrough_vp;
struct gl_fragment_program *saved_fp;
GLboolean saved_fp_enable;
struct gl_vertex_program *saved_vp;
GLboolean saved_vp_enable;
GLint saved_vp_x, saved_vp_y;
GLsizei saved_vp_width, saved_vp_height;
} meta;
GLint refcount;
GLuint Fallback;
GLuint NewGLState;
@ -166,7 +179,6 @@ struct intel_context
struct intel_region *front_region;
struct intel_region *back_region;
struct intel_region *third_region;
struct intel_region *depth_region;
/**

View file

@ -27,7 +27,12 @@
#include "main/enums.h"
#include "main/state.h"
#include "main/context.h"
#include "main/enable.h"
#include "main/matrix.h"
#include "swrast/swrast.h"
#include "shader/arbprogram.h"
#include "shader/program.h"
#include "intel_context.h"
#include "intel_pixel.h"
@ -167,6 +172,159 @@ intel_check_blit_format(struct intel_region * region,
return GL_FALSE;
}
void
intel_meta_set_passthrough_transform(struct intel_context *intel)
{
GLcontext *ctx = &intel->ctx;
intel->meta.saved_vp_x = ctx->Viewport.X;
intel->meta.saved_vp_y = ctx->Viewport.Y;
intel->meta.saved_vp_width = ctx->Viewport.Width;
intel->meta.saved_vp_height = ctx->Viewport.Height;
_mesa_Viewport(0, 0, ctx->DrawBuffer->Width, ctx->DrawBuffer->Height);
_mesa_MatrixMode(GL_PROJECTION);
_mesa_PushMatrix();
_mesa_LoadIdentity();
_mesa_Ortho(0, ctx->DrawBuffer->Width, 0, ctx->DrawBuffer->Height, 1, -1);
_mesa_MatrixMode(GL_MODELVIEW);
_mesa_PushMatrix();
_mesa_LoadIdentity();
}
void
intel_meta_restore_transform(struct intel_context *intel)
{
_mesa_MatrixMode(GL_PROJECTION);
_mesa_PopMatrix();
_mesa_MatrixMode(GL_MODELVIEW);
_mesa_PopMatrix();
_mesa_Viewport(intel->meta.saved_vp_x, intel->meta.saved_vp_y,
intel->meta.saved_vp_width, intel->meta.saved_vp_height);
}
/**
* Set up a vertex program to pass through the position and first texcoord
* for pixel path.
*/
void
intel_meta_set_passthrough_vertex_program(struct intel_context *intel)
{
GLcontext *ctx = &intel->ctx;
static const char *vp =
"!!ARBvp1.0\n"
"TEMP vertexClip;\n"
"DP4 vertexClip.x, state.matrix.mvp.row[0], vertex.position;\n"
"DP4 vertexClip.y, state.matrix.mvp.row[1], vertex.position;\n"
"DP4 vertexClip.z, state.matrix.mvp.row[2], vertex.position;\n"
"DP4 vertexClip.w, state.matrix.mvp.row[3], vertex.position;\n"
"MOV result.position, vertexClip;\n"
"MOV result.texcoord[0], vertex.texcoord[0];\n"
"MOV result.color, vertex.color;\n"
"END\n";
assert(intel->meta.saved_vp == NULL);
_mesa_reference_vertprog(ctx, &intel->meta.saved_vp,
ctx->VertexProgram.Current);
if (intel->meta.passthrough_vp == NULL) {
GLuint prog_name;
_mesa_GenPrograms(1, &prog_name);
_mesa_BindProgram(GL_VERTEX_PROGRAM_ARB, prog_name);
_mesa_ProgramStringARB(GL_VERTEX_PROGRAM_ARB,
GL_PROGRAM_FORMAT_ASCII_ARB,
strlen(vp), (const GLubyte *)vp);
_mesa_reference_vertprog(ctx, &intel->meta.passthrough_vp,
ctx->VertexProgram.Current);
_mesa_DeletePrograms(1, &prog_name);
}
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
_mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current,
intel->meta.passthrough_vp);
ctx->Driver.BindProgram(ctx, GL_VERTEX_PROGRAM_ARB,
&intel->meta.passthrough_vp->Base);
intel->meta.saved_vp_enable = ctx->VertexProgram.Enabled;
_mesa_Enable(GL_VERTEX_PROGRAM_ARB);
}
/**
* Restores the previous vertex program after
* intel_meta_set_passthrough_vertex_program()
*/
void
intel_meta_restore_vertex_program(struct intel_context *intel)
{
GLcontext *ctx = &intel->ctx;
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
_mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current,
intel->meta.saved_vp);
_mesa_reference_vertprog(ctx, &intel->meta.saved_vp, NULL);
ctx->Driver.BindProgram(ctx, GL_VERTEX_PROGRAM_ARB,
&ctx->VertexProgram.Current->Base);
if (!intel->meta.saved_vp_enable)
_mesa_Disable(GL_VERTEX_PROGRAM_ARB);
}
/**
* Binds the given program string to GL_FRAGMENT_PROGRAM_ARB, caching the
* program object.
*/
void
intel_meta_set_fragment_program(struct intel_context *intel,
struct gl_fragment_program **prog,
const char *prog_string)
{
GLcontext *ctx = &intel->ctx;
assert(intel->meta.saved_fp == NULL);
_mesa_reference_fragprog(ctx, &intel->meta.saved_fp,
ctx->FragmentProgram.Current);
if (*prog == NULL) {
GLuint prog_name;
_mesa_GenPrograms(1, &prog_name);
_mesa_BindProgram(GL_FRAGMENT_PROGRAM_ARB, prog_name);
_mesa_ProgramStringARB(GL_FRAGMENT_PROGRAM_ARB,
GL_PROGRAM_FORMAT_ASCII_ARB,
strlen(prog_string), (const GLubyte *)prog_string);
_mesa_reference_fragprog(ctx, prog, ctx->FragmentProgram.Current);
/* Note that DeletePrograms unbinds the program on us */
_mesa_DeletePrograms(1, &prog_name);
}
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, *prog);
ctx->Driver.BindProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, &((*prog)->Base));
intel->meta.saved_fp_enable = ctx->FragmentProgram.Enabled;
_mesa_Enable(GL_FRAGMENT_PROGRAM_ARB);
}
/**
* Restores the previous fragment program after
* intel_meta_set_fragment_program()
*/
void
intel_meta_restore_fragment_program(struct intel_context *intel)
{
GLcontext *ctx = &intel->ctx;
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current,
intel->meta.saved_fp);
_mesa_reference_fragprog(ctx, &intel->meta.saved_fp, NULL);
ctx->Driver.BindProgram(ctx, GL_FRAGMENT_PROGRAM_ARB,
&ctx->FragmentProgram.Current->Base);
if (!intel->meta.saved_fp_enable)
_mesa_Disable(GL_FRAGMENT_PROGRAM_ARB);
}
void
intelInitPixelFuncs(struct dd_function_table *functions)
@ -181,3 +339,13 @@ intelInitPixelFuncs(struct dd_function_table *functions)
#endif
}
}
void
intel_free_pixel_state(struct intel_context *intel)
{
GLcontext *ctx = &intel->ctx;
_mesa_reference_vertprog(ctx, &intel->meta.passthrough_vp, NULL);
_mesa_reference_fragprog(ctx, &intel->meta.bitmap_fp, NULL);
}

View file

@ -31,6 +31,15 @@
#include "main/mtypes.h"
void intelInitPixelFuncs(struct dd_function_table *functions);
void intel_meta_set_passthrough_transform(struct intel_context *intel);
void intel_meta_restore_transform(struct intel_context *intel);
void intel_meta_set_passthrough_vertex_program(struct intel_context *intel);
void intel_meta_restore_vertex_program(struct intel_context *intel);
void intel_meta_set_fragment_program(struct intel_context *intel,
struct gl_fragment_program **prog,
const char *prog_string);
void intel_meta_restore_fragment_program(struct intel_context *intel);
void intel_free_pixel_state(struct intel_context *intel);
GLboolean intel_check_blit_fragment_ops(GLcontext * ctx,
GLboolean src_alpha_is_one);

View file

@ -32,7 +32,18 @@
#include "main/mtypes.h"
#include "main/macros.h"
#include "main/bufferobj.h"
#include "main/pixelstore.h"
#include "main/state.h"
#include "main/teximage.h"
#include "main/texenv.h"
#include "main/texobj.h"
#include "main/texstate.h"
#include "main/texparam.h"
#include "main/varray.h"
#include "main/attrib.h"
#include "main/enable.h"
#include "shader/arbprogram.h"
#include "glapi/dispatch.h"
#include "swrast/swrast.h"
#include "intel_screen.h"
@ -87,6 +98,11 @@ static GLboolean test_bit( const GLubyte *src,
return (src[bit/8] & (1<<(bit % 8))) ? 1 : 0;
}
static GLboolean test_msb_bit(const GLubyte *src, GLuint bit)
{
return (src[bit/8] & (1<<(7 - (bit % 8)))) ? 1 : 0;
}
static void set_bit( GLubyte *dest,
GLuint bit )
{
@ -244,8 +260,8 @@ do_blit_bitmap( GLcontext *ctx,
/* Clip to drawable cliprect */
if (!_mesa_clip_to_region(cliprects[i].x1,
cliprects[i].y1,
cliprects[i].x2 - cliprects[i].x1,
cliprects[i].y2 - cliprects[i].y1,
cliprects[i].x2,
cliprects[i].y2,
&box_x, &box_y, &box_w, &box_h))
continue;
@ -317,9 +333,174 @@ out:
return GL_TRUE;
}
static GLboolean
intel_texture_bitmap(GLcontext * ctx,
GLint dst_x, GLint dst_y,
GLsizei width, GLsizei height,
const struct gl_pixelstore_attrib *unpack,
const GLubyte *bitmap)
{
struct intel_context *intel = intel_context(ctx);
static const char *fp =
"!!ARBfp1.0\n"
"TEMP val;\n"
"PARAM color=program.local[0];\n"
"TEX val, fragment.texcoord[0], texture[0], 2D;\n"
"ADD val, val.wwww, {-.5, -.5, -.5, -.5};\n"
"KIL val;\n"
"MOV result.color, color;\n"
"END\n";
GLuint texname;
GLfloat vertices[4][4];
GLfloat texcoords[4][2];
GLint old_active_texture;
GLubyte *unpacked_bitmap;
GLubyte *a8_bitmap;
int x, y;
/* We need a fragment program for the KIL effect */
if (!ctx->Extensions.ARB_fragment_program ||
!ctx->Extensions.ARB_vertex_program) {
if (INTEL_DEBUG & DEBUG_FALLBACKS)
fprintf(stderr,
"glBitmap fallback: No fragment/vertex program support\n");
return GL_FALSE;
}
/* We're going to mess with texturing with no regard to existing texture
* state, so if there is some set up we have to bail.
*/
if (ctx->Texture._EnabledUnits != 0) {
if (INTEL_DEBUG & DEBUG_FALLBACKS)
fprintf(stderr, "glBitmap fallback: texturing enabled\n");
return GL_FALSE;
}
/* Can't do textured DrawPixels with a fragment program, unless we were
* to generate a new program that sampled our texture and put the results
* in the fragment color before the user's program started.
*/
if (ctx->FragmentProgram.Enabled) {
if (INTEL_DEBUG & DEBUG_FALLBACKS)
fprintf(stderr, "glBitmap fallback: fragment program enabled\n");
return GL_FALSE;
}
if (ctx->VertexProgram.Enabled) {
if (INTEL_DEBUG & DEBUG_FALLBACKS)
fprintf(stderr, "glBitmap fallback: vertex program enabled\n");
return GL_FALSE;
}
/* Check that we can load in a texture this big. */
if (width > (1 << (ctx->Const.MaxTextureLevels - 1)) ||
height > (1 << (ctx->Const.MaxTextureLevels - 1))) {
if (INTEL_DEBUG & DEBUG_FALLBACKS)
fprintf(stderr, "glBitmap fallback: bitmap too large (%dx%d)\n",
width, height);
return GL_FALSE;
}
/* Convert the A1 bitmap to an A8 format suitable for glTexImage */
if (unpack->BufferObj->Name) {
bitmap = map_pbo(ctx, width, height, unpack, bitmap);
if (bitmap == NULL)
return GL_TRUE; /* even though this is an error, we're done */
}
unpacked_bitmap = _mesa_unpack_bitmap(width, height, bitmap,
unpack);
a8_bitmap = _mesa_calloc(width * height);
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
if (test_msb_bit(unpacked_bitmap, ALIGN(width, 8) * y + x))
a8_bitmap[y * width + x] = 0xff;
}
}
_mesa_free(unpacked_bitmap);
if (unpack->BufferObj->Name) {
/* done with PBO so unmap it now */
ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
unpack->BufferObj);
}
/* Save GL state before we start setting up our drawing */
_mesa_PushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT |
GL_VIEWPORT_BIT);
_mesa_PushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT |
GL_CLIENT_PIXEL_STORE_BIT);
old_active_texture = ctx->Texture.CurrentUnit;
_mesa_Disable(GL_POLYGON_STIPPLE);
/* Upload our bitmap data to an alpha texture */
_mesa_ActiveTextureARB(GL_TEXTURE0_ARB);
_mesa_Enable(GL_TEXTURE_2D);
_mesa_GenTextures(1, &texname);
_mesa_BindTexture(GL_TEXTURE_2D, texname);
_mesa_TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
_mesa_TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
_mesa_PixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
_mesa_PixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
_mesa_PixelStorei(GL_UNPACK_ROW_LENGTH, 0);
_mesa_PixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
_mesa_PixelStorei(GL_UNPACK_SKIP_ROWS, 0);
_mesa_PixelStorei(GL_UNPACK_ALIGNMENT, 1);
_mesa_TexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0,
GL_ALPHA, GL_UNSIGNED_BYTE, a8_bitmap);
_mesa_free(a8_bitmap);
intel_meta_set_fragment_program(intel, &intel->meta.bitmap_fp, fp);
_mesa_ProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, 0,
ctx->Current.RasterColor);
intel_meta_set_passthrough_vertex_program(intel);
intel_meta_set_passthrough_transform(intel);
vertices[0][0] = dst_x;
vertices[0][1] = dst_y;
vertices[0][2] = ctx->Current.RasterPos[2];
vertices[0][3] = 1.0;
vertices[1][0] = dst_x + width;
vertices[1][1] = dst_y;
vertices[1][2] = ctx->Current.RasterPos[2];
vertices[1][3] = 1.0;
vertices[2][0] = dst_x + width;
vertices[2][1] = dst_y + height;
vertices[2][2] = ctx->Current.RasterPos[2];
vertices[2][3] = 1.0;
vertices[3][0] = dst_x;
vertices[3][1] = dst_y + height;
vertices[3][2] = ctx->Current.RasterPos[2];
vertices[3][3] = 1.0;
texcoords[0][0] = 0.0;
texcoords[0][1] = 0.0;
texcoords[1][0] = 1.0;
texcoords[1][1] = 0.0;
texcoords[2][0] = 1.0;
texcoords[2][1] = 1.0;
texcoords[3][0] = 0.0;
texcoords[3][1] = 1.0;
_mesa_VertexPointer(4, GL_FLOAT, 4 * sizeof(GLfloat), &vertices);
_mesa_TexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), &texcoords);
_mesa_Enable(GL_VERTEX_ARRAY);
_mesa_Enable(GL_TEXTURE_COORD_ARRAY);
CALL_DrawArrays(ctx->Exec, (GL_TRIANGLE_FAN, 0, 4));
intel_meta_restore_transform(intel);
intel_meta_restore_fragment_program(intel);
intel_meta_restore_vertex_program(intel);
_mesa_PopClientAttrib();
_mesa_Disable(GL_TEXTURE_2D); /* asserted that it was disabled at entry */
_mesa_ActiveTextureARB(GL_TEXTURE0_ARB + old_active_texture);
_mesa_PopAttrib();
_mesa_DeleteTextures(1, &texname);
return GL_TRUE;
}
/* There are a large number of possible ways to implement bitmap on
* this hardware, most of them have some sort of drawback. Here are a
@ -352,6 +533,10 @@ intelBitmap(GLcontext * ctx,
unpack, pixels))
return;
if (intel_texture_bitmap(ctx, x, y, width, height,
unpack, pixels))
return;
if (INTEL_DEBUG & DEBUG_PIXEL)
_mesa_printf("%s: fallback to swrast\n", __FUNCTION__);

View file

@ -36,7 +36,6 @@
#include "main/texobj.h"
#include "main/texstate.h"
#include "main/texparam.h"
#include "main/matrix.h"
#include "main/varray.h"
#include "main/attrib.h"
#include "main/enable.h"
@ -68,6 +67,7 @@ intel_texture_drawpixels(GLcontext * ctx,
const struct gl_pixelstore_attrib *unpack,
const GLvoid *pixels)
{
struct intel_context *intel = intel_context(ctx);
GLuint texname;
GLfloat vertices[4][4];
GLfloat texcoords[4][2];
@ -117,7 +117,7 @@ intel_texture_drawpixels(GLcontext * ctx,
return GL_FALSE;
}
_mesa_PushAttrib(GL_ENABLE_BIT | GL_TRANSFORM_BIT | GL_TEXTURE_BIT |
_mesa_PushAttrib(GL_ENABLE_BIT | GL_TEXTURE_BIT |
GL_CURRENT_BIT);
_mesa_PushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
@ -138,14 +138,7 @@ intel_texture_drawpixels(GLcontext * ctx,
_mesa_TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, format,
type, pixels);
_mesa_MatrixMode(GL_PROJECTION);
_mesa_PushMatrix();
_mesa_LoadIdentity();
_mesa_Ortho(0, ctx->DrawBuffer->Width, 0, ctx->DrawBuffer->Height, 1, -1);
_mesa_MatrixMode(GL_MODELVIEW);
_mesa_PushMatrix();
_mesa_LoadIdentity();
intel_meta_set_passthrough_transform(intel);
/* Create the vertex buffer based on the current raster pos. The x and y
* we're handed are ctx->Current.RasterPos[0,1] rounded to integers.
@ -184,10 +177,7 @@ intel_texture_drawpixels(GLcontext * ctx,
_mesa_Enable(GL_TEXTURE_COORD_ARRAY);
CALL_DrawArrays(ctx->Exec, (GL_TRIANGLE_FAN, 0, 4));
_mesa_MatrixMode(GL_PROJECTION);
_mesa_PopMatrix();
_mesa_MatrixMode(GL_MODELVIEW);
_mesa_PopMatrix();
intel_meta_restore_transform(intel);
_mesa_PopClientAttrib();
_mesa_PopAttrib();
@ -205,6 +195,7 @@ intel_stencil_drawpixels(GLcontext * ctx,
const struct gl_pixelstore_attrib *unpack,
const GLvoid *pixels)
{
struct intel_context *intel = intel_context(ctx);
GLuint texname, rb_name, fb_name, old_fb_name;
GLfloat vertices[4][2];
GLfloat texcoords[4][2];
@ -267,7 +258,7 @@ intel_stencil_drawpixels(GLcontext * ctx,
return GL_FALSE;
}
_mesa_PushAttrib(GL_ENABLE_BIT | GL_TRANSFORM_BIT | GL_TEXTURE_BIT |
_mesa_PushAttrib(GL_ENABLE_BIT | GL_TEXTURE_BIT |
GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
_mesa_PushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
old_fb_name = ctx->DrawBuffer->Name;
@ -335,14 +326,7 @@ intel_stencil_drawpixels(GLcontext * ctx,
ctx->Unpack = old_unpack;
_mesa_free(stencil_pixels);
_mesa_MatrixMode(GL_PROJECTION);
_mesa_PushMatrix();
_mesa_LoadIdentity();
_mesa_Ortho(0, ctx->DrawBuffer->Width, 0, ctx->DrawBuffer->Height, 1, -1);
_mesa_MatrixMode(GL_MODELVIEW);
_mesa_PushMatrix();
_mesa_LoadIdentity();
intel_meta_set_passthrough_transform(intel);
vertices[0][0] = x;
vertices[0][1] = y;
@ -368,12 +352,10 @@ intel_stencil_drawpixels(GLcontext * ctx,
_mesa_Enable(GL_TEXTURE_COORD_ARRAY);
CALL_DrawArrays(ctx->Exec, (GL_TRIANGLE_FAN, 0, 4));
intel_meta_restore_transform(intel);
_mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, old_fb_name);
_mesa_MatrixMode(GL_PROJECTION);
_mesa_PopMatrix();
_mesa_MatrixMode(GL_MODELVIEW);
_mesa_PopMatrix();
_mesa_PopClientAttrib();
_mesa_PopAttrib();

View file

@ -550,15 +550,6 @@ intel_recreate_static_regions(struct intel_context *intel)
intel->back_region,
&intelScreen->back);
#ifdef I915
if (intelScreen->third.handle) {
intel->third_region =
intel_recreate_static(intel, "third",
intel->third_region,
&intelScreen->third);
}
#endif /* I915 */
/* Still assumes front.cpp == depth.cpp. We can kill this when we move to
* private buffers.
*/

View file

@ -177,13 +177,6 @@ intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen,
intelScreen->back.size = sarea->back_size;
intelScreen->back.tiled = sarea->back_tiled;
if (intelScreen->driScrnPriv->ddx_version.minor >= 8) {
intelScreen->third.offset = sarea->third_offset;
intelScreen->third.handle = sarea->third_handle;
intelScreen->third.size = sarea->third_size;
intelScreen->third.tiled = sarea->third_tiled;
}
intelScreen->depth.offset = sarea->depth_offset;
intelScreen->depth.handle = sarea->depth_handle;
intelScreen->depth.size = sarea->depth_size;
@ -192,12 +185,10 @@ intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen,
if (intelScreen->driScrnPriv->ddx_version.minor >= 9) {
intelScreen->front.bo_handle = sarea->front_bo_handle;
intelScreen->back.bo_handle = sarea->back_bo_handle;
intelScreen->third.bo_handle = sarea->third_bo_handle;
intelScreen->depth.bo_handle = sarea->depth_bo_handle;
} else {
intelScreen->front.bo_handle = -1;
intelScreen->back.bo_handle = -1;
intelScreen->third.bo_handle = -1;
intelScreen->depth.bo_handle = -1;
}
@ -353,12 +344,6 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
_mesa_add_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT,
&intel_fb->color_rb[1]->Base);
if (screen->third.handle) {
struct gl_renderbuffer *tmp_rb = NULL;
intel_fb->color_rb[2] = intel_create_renderbuffer(rgbFormat);
_mesa_reference_renderbuffer(&tmp_rb, &intel_fb->color_rb[2]->Base);
}
}
if (mesaVis->depthBits == 24) {

View file

@ -56,7 +56,6 @@ typedef struct
{
intelRegion front;
intelRegion back;
intelRegion third;
intelRegion depth;
intelRegion tex;

View file

@ -64,7 +64,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define R300_SE_VPORT_ZSCALE 0x1DA8
#define R300_SE_VPORT_ZOFFSET 0x1DAC
#define R300_VAP_PORT_IDX0 0x2040
/*
* Vertex Array Processing (VAP) Control
*/
@ -3201,9 +3201,9 @@ enum {
#define R300_PACKET3_3D_LOAD_VBPNTR 0x00002F00
#define R300_PACKET3_INDX_BUFFER 0x00003300
# define R300_EB_UNK1_SHIFT 24
# define R300_EB_UNK1 (0x80<<24)
# define R300_EB_UNK2 0x0810
# define R300_INDX_BUFFER_DST_SHIFT 0
# define R300_INDX_BUFFER_SKIP_SHIFT 16
# define R300_INDX_BUFFER_ONE_REG_WR (1<<31)
/* Same as R300_PACKET3_3D_DRAW_VBUF but without VAP_VTX_FMT */
#define R300_PACKET3_3D_DRAW_VBUF_2 0x00003400

View file

@ -208,7 +208,8 @@ static void r300FireEB(r300ContextPtr rmesa, unsigned long addr,
e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (vertex_count << 16) | type | R300_VAP_VF_CNTL__INDEX_SIZE_32bit);
start_packet3(CP_PACKET3(R300_PACKET3_INDX_BUFFER, 2), 2);
e32(R300_EB_UNK1 | (0 << 16) | R300_EB_UNK2);
e32(R300_INDX_BUFFER_ONE_REG_WR | (0 << R300_INDX_BUFFER_SKIP_SHIFT) |
(R300_VAP_PORT_IDX0 >> 2));
e32(addr);
e32(vertex_count);
}

View file

@ -142,7 +142,7 @@ _mesa_initialize_array_object( GLcontext *ctx,
obj->Index.StrideB = 0;
obj->Index.Ptr = NULL;
obj->Index.Enabled = GL_FALSE;
for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
obj->TexCoord[i].Size = 4;
obj->TexCoord[i].Type = GL_FLOAT;
obj->TexCoord[i].Stride = 0;
@ -181,7 +181,7 @@ _mesa_initialize_array_object( GLcontext *ctx,
obj->SecondaryColor.BufferObj = ctx->Array.NullBufferObj;
obj->FogCoord.BufferObj = ctx->Array.NullBufferObj;
obj->Index.BufferObj = ctx->Array.NullBufferObj;
for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
obj->TexCoord[i].BufferObj = ctx->Array.NullBufferObj;
}
obj->EdgeFlag.BufferObj = ctx->Array.NullBufferObj;
@ -335,7 +335,7 @@ _mesa_DeleteVertexArraysAPPLE(GLsizei n, const GLuint *ids)
unbind_buffer_object( ctx, obj->SecondaryColor.BufferObj );
unbind_buffer_object( ctx, obj->FogCoord.BufferObj );
unbind_buffer_object( ctx, obj->Index.BufferObj );
for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
unbind_buffer_object( ctx, obj->TexCoord[i].BufferObj );
}
unbind_buffer_object( ctx, obj->EdgeFlag.BufferObj );

View file

@ -1,8 +1,9 @@
/*
* Mesa 3-D graphics library
* Version: 7.2
* Version: 7.3
*
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@ -224,7 +225,7 @@ _mesa_PushAttrib(GLbitfield mask)
attr->SampleAlphaToOne = ctx->Multisample.SampleAlphaToOne;
attr->SampleCoverage = ctx->Multisample.SampleCoverage;
attr->SampleCoverageInvert = ctx->Multisample.SampleCoverageInvert;
for (i=0; i<MAX_TEXTURE_UNITS; i++) {
for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
attr->Texture[i] = ctx->Texture.Unit[i].Enabled;
attr->TexGen[i] = ctx->Texture.Unit[i].TexGenEnabled;
attr->TextureColorTable[i] = ctx->Texture.Unit[i].ColorTableEnabled;

View file

@ -808,7 +808,7 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
unbind(ctx, &ctx->Array.ArrayObj->FogCoord.BufferObj, bufObj);
unbind(ctx, &ctx->Array.ArrayObj->Index.BufferObj, bufObj);
unbind(ctx, &ctx->Array.ArrayObj->EdgeFlag.BufferObj, bufObj);
for (j = 0; j < MAX_TEXTURE_UNITS; j++) {
for (j = 0; j < MAX_TEXTURE_COORD_UNITS; j++) {
unbind(ctx, &ctx->Array.ArrayObj->TexCoord[j].BufferObj, bufObj);
}
for (j = 0; j < VERT_ATTRIB_MAX; j++) {

View file

@ -1,13 +1,9 @@
/**
* \file config.h
* Tunable configuration parameters.
*/
/*
* Mesa 3-D graphics library
* Version: 7.1
* Version: 7.3
*
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
* Copyright (C) 2008 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@ -27,6 +23,10 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file config.h
* Tunable configuration parameters.
*/
#ifndef MESA_CONFIG_H_INCLUDED
#define MESA_CONFIG_H_INCLUDED
@ -115,27 +115,28 @@
/** Maximum number of layers in a 1D or 2D array texture - GL_MESA_texture_array */
#define MAX_ARRAY_TEXTURE_LAYERS 64
/** Number of texture units - GL_ARB_multitexture
* This needs to be the larger of MAX_TEXTURE_COORD_UNITS and
* MAX_TEXTURE_IMAGE_UNITS seen below, since MAX_TEXTURE_UNITS is used
* to dimension some arrays that store both coord and image data.
*/
#define MAX_TEXTURE_UNITS 8
/*@}*/
/**
* Max number of texture coordinate units. This mainly just applies to
* the fixed-function vertex code. This will be difficult to raise above
* eight because of various vertex attribute bitvectors.
*/
#define MAX_TEXTURE_COORD_UNITS 8
/**
* \name Separate numbers of texture coordinates and texture image units.
*
* These values will eventually replace most instances of MAX_TEXTURE_UNITS.
* We should always have MAX_TEXTURE_COORD_UNITS <= MAX_TEXTURE_IMAGE_UNITS.
* And, GL_MAX_TEXTURE_UNITS <= MAX_TEXTURE_COORD_UNITS.
* Max number of texture image units. Also determines number of texture
* samplers in shaders.
*/
/*@{*/
#define MAX_TEXTURE_COORD_UNITS 8
#define MAX_TEXTURE_IMAGE_UNITS 8
/*@}*/
#define MAX_TEXTURE_IMAGE_UNITS 16
/**
* Larger of MAX_TEXTURE_COORD_UNITS and MAX_TEXTURE_IMAGE_UNITS.
* This value is only used for dimensioning arrays.
* Either MAX_TEXTURE_COORD_UNITS or MAX_TEXTURE_IMAGE_UNITS (or the
* corresponding ctx->Const.MaxTextureCoord/ImageUnits fields) should be
* used almost everywhere else.
*/
#define MAX_TEXTURE_UNITS ((MAX_TEXTURE_COORD_UNITS > MAX_TEXTURE_IMAGE_UNITS) ? MAX_TEXTURE_COORD_UNITS : MAX_TEXTURE_IMAGE_UNITS)
/**
* Maximum viewport/image width. Must accomodate all texture sizes too.
@ -181,16 +182,16 @@
/** For any program target/extension */
/*@{*/
#define MAX_PROGRAM_INSTRUCTIONS (16 * 1024)
#define MAX_PROGRAM_LOCAL_PARAMS 128 /* KW: power of two */
#define MAX_PROGRAM_LOCAL_PARAMS 256 /**< per-program constants (power of two) */
#define MAX_PROGRAM_ENV_PARAMS 128
#define MAX_PROGRAM_MATRICES 8
#define MAX_PROGRAM_MATRIX_STACK_DEPTH 4
#define MAX_PROGRAM_CALL_DEPTH 8
#define MAX_PROGRAM_TEMPS 128
#define MAX_PROGRAM_ADDRESS_REGS 2
#define MAX_UNIFORMS 128 /**< number of float components */
#define MAX_UNIFORMS 256 /**< number of vec4 uniforms */
#define MAX_VARYING 8 /**< number of float[4] vectors */
#define MAX_SAMPLERS 8
#define MAX_SAMPLERS MAX_TEXTURE_IMAGE_UNITS
#define MAX_PROGRAM_INPUTS 32
#define MAX_PROGRAM_OUTPUTS 32
/*@}*/
@ -218,8 +219,8 @@
/** For GL_ARB_vertex_shader */
/*@{*/
#define MAX_VERTEX_ATTRIBS 16
#define MAX_VERTEX_TEXTURE_IMAGE_UNITS MAX_TEXTURE_UNITS
#define MAX_COMBINED_TEXTURE_IMAGE_UNITS (MAX_TEXTURE_IMAGE_UNITS + MAX_VERTEX_TEXTURE_IMAGE_UNITS)
#define MAX_VERTEX_TEXTURE_IMAGE_UNITS MAX_TEXTURE_IMAGE_UNITS
#define MAX_COMBINED_TEXTURE_IMAGE_UNITS MAX_TEXTURE_IMAGE_UNITS
/*@}*/

View file

@ -1,14 +1,9 @@
/**
* \file context.c
* Mesa context/visual/framebuffer management functions.
* \author Brian Paul
*/
/*
* Mesa 3-D graphics library
* Version: 7.1
* Version: 7.3
*
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
* Copyright (C) 2008 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@ -28,6 +23,11 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file context.c
* Mesa context/visual/framebuffer management functions.
* \author Brian Paul
*/
/**
* \mainpage Mesa Main Module
@ -870,9 +870,6 @@ _mesa_init_constants(GLcontext *ctx)
assert(MAX_TEXTURE_LEVELS >= MAX_3D_TEXTURE_LEVELS);
assert(MAX_TEXTURE_LEVELS >= MAX_CUBE_TEXTURE_LEVELS);
assert(MAX_TEXTURE_UNITS >= MAX_TEXTURE_COORD_UNITS);
assert(MAX_TEXTURE_UNITS >= MAX_TEXTURE_IMAGE_UNITS);
/* Constants, may be overriden (usually only reduced) by device drivers */
ctx->Const.MaxTextureLevels = MAX_TEXTURE_LEVELS;
ctx->Const.Max3DTextureLevels = MAX_3D_TEXTURE_LEVELS;
@ -963,6 +960,9 @@ check_context_limits(GLcontext *ctx)
assert(ctx->Const.MaxTextureUnits <= MAX_TEXTURE_IMAGE_UNITS);
assert(ctx->Const.MaxTextureUnits <= MAX_TEXTURE_COORD_UNITS);
/* number of coord units cannot be greater than number of image units */
assert(ctx->Const.MaxTextureCoordUnits <= ctx->Const.MaxTextureImageUnits);
assert(ctx->Const.MaxViewportWidth <= MAX_WIDTH);
assert(ctx->Const.MaxViewportHeight <= MAX_WIDTH);

View file

@ -48,7 +48,7 @@ _mesa_dlopen(const char *libname, int flags)
flags = RTLD_LAZY | RTLD_GLOBAL; /* Overriding flags at this time */
return dlopen(libname, flags);
#elif defined(__MINGW32__)
return LoadLibrary(libname);
return LoadLibraryA(libname);
#else
return NULL;
#endif

View file

@ -201,6 +201,26 @@ _mesa_DisableClientState( GLenum cap )
}
/**
* Return pointer to current texture unit for setting/getting coordinate
* state.
* Note that we'll set GL_INVALID_OPERATION if the active texture unit is
* higher than the number of supported coordinate units. And we'll return NULL.
*/
static struct gl_texture_unit *
get_texcoord_unit(GLcontext *ctx)
{
if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glEnable/Disable(texcoord unit)");
return NULL;
}
else {
return &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
}
}
/**
* Helper function to enable or disable a texture target.
*/
@ -612,54 +632,62 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state)
return;
}
break;
case GL_TEXTURE_GEN_Q: {
GLuint unit = ctx->Texture.CurrentUnit;
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
GLuint newenabled = texUnit->TexGenEnabled & ~Q_BIT;
if (state)
newenabled |= Q_BIT;
if (texUnit->TexGenEnabled == newenabled)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texUnit->TexGenEnabled = newenabled;
case GL_TEXTURE_GEN_Q:
{
struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
if (texUnit) {
GLuint newenabled = texUnit->TexGenEnabled & ~Q_BIT;
if (state)
newenabled |= Q_BIT;
if (texUnit->TexGenEnabled == newenabled)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texUnit->TexGenEnabled = newenabled;
}
}
break;
}
case GL_TEXTURE_GEN_R: {
GLuint unit = ctx->Texture.CurrentUnit;
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
GLuint newenabled = texUnit->TexGenEnabled & ~R_BIT;
if (state)
newenabled |= R_BIT;
if (texUnit->TexGenEnabled == newenabled)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texUnit->TexGenEnabled = newenabled;
case GL_TEXTURE_GEN_R:
{
struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
if (texUnit) {
GLuint newenabled = texUnit->TexGenEnabled & ~R_BIT;
if (state)
newenabled |= R_BIT;
if (texUnit->TexGenEnabled == newenabled)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texUnit->TexGenEnabled = newenabled;
}
}
break;
}
case GL_TEXTURE_GEN_S: {
GLuint unit = ctx->Texture.CurrentUnit;
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
GLuint newenabled = texUnit->TexGenEnabled & ~S_BIT;
if (state)
newenabled |= S_BIT;
if (texUnit->TexGenEnabled == newenabled)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texUnit->TexGenEnabled = newenabled;
case GL_TEXTURE_GEN_S:
{
struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
if (texUnit) {
GLuint newenabled = texUnit->TexGenEnabled & ~S_BIT;
if (state)
newenabled |= S_BIT;
if (texUnit->TexGenEnabled == newenabled)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texUnit->TexGenEnabled = newenabled;
}
}
break;
}
case GL_TEXTURE_GEN_T: {
GLuint unit = ctx->Texture.CurrentUnit;
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
GLuint newenabled = texUnit->TexGenEnabled & ~T_BIT;
if (state)
newenabled |= T_BIT;
if (texUnit->TexGenEnabled == newenabled)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texUnit->TexGenEnabled = newenabled;
case GL_TEXTURE_GEN_T:
{
struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
if (texUnit) {
GLuint newenabled = texUnit->TexGenEnabled & ~T_BIT;
if (state)
newenabled |= T_BIT;
if (texUnit->TexGenEnabled == newenabled)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texUnit->TexGenEnabled = newenabled;
}
}
break;
}
/*
* CLIENT STATE!!!
@ -1155,28 +1183,36 @@ _mesa_IsEnabled( GLenum cap )
return is_texture_enabled(ctx, TEXTURE_3D_BIT);
case GL_TEXTURE_GEN_Q:
{
const struct gl_texture_unit *texUnit;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE;
const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
if (texUnit) {
return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE;
}
}
return GL_FALSE;
case GL_TEXTURE_GEN_R:
{
const struct gl_texture_unit *texUnit;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE;
const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
if (texUnit) {
return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE;
}
}
return GL_FALSE;
case GL_TEXTURE_GEN_S:
{
const struct gl_texture_unit *texUnit;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE;
const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
if (texUnit) {
return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE;
}
}
return GL_FALSE;
case GL_TEXTURE_GEN_T:
{
const struct gl_texture_unit *texUnit;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE;
const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
if (texUnit) {
return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE;
}
}
return GL_FALSE;
/*
* CLIENT STATE!!!

View file

@ -26,7 +26,7 @@
**************************************************************************/
/**
* \file ffvertex_prog.
* \file ffvertex_prog.c
*
* Create a vertex program to execute the current fixed function T&L pipeline.
* \author Keith Whitwell
@ -101,6 +101,7 @@ static GLuint translate_fog_mode( GLenum mode )
}
}
#define TXG_NONE 0
#define TXG_OBJ_LINEAR 1
#define TXG_EYE_LINEAR 2
@ -145,6 +146,7 @@ tnl_get_per_vertex_materials(GLcontext *ctx)
return mask;
}
/**
* Should fog be computed per-vertex?
*/
@ -159,6 +161,7 @@ tnl_get_per_vertex_fog(GLcontext *ctx)
#endif
}
static GLboolean check_active_shininess( GLcontext *ctx,
const struct state_key *key,
GLuint side )
@ -176,8 +179,6 @@ static GLboolean check_active_shininess( GLcontext *ctx,
return GL_FALSE;
}
static void make_state_key( GLcontext *ctx, struct state_key *key )
@ -278,7 +279,7 @@ static void make_state_key( GLcontext *ctx, struct state_key *key )
ctx->Texture._EnabledUnits)
key->texture_enabled_global = 1;
for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
if (texUnit->_ReallyEnabled)
@ -410,11 +411,13 @@ static struct ureg swizzle( struct ureg reg, int x, int y, int z, int w )
return reg;
}
static struct ureg swizzle1( struct ureg reg, int x )
{
return swizzle(reg, x, x, x, x);
}
static struct ureg get_temp( struct tnl_program *p )
{
int bit = _mesa_ffs( ~p->temp_in_use );
@ -430,6 +433,7 @@ static struct ureg get_temp( struct tnl_program *p )
return make_ureg(PROGRAM_TEMPORARY, bit-1);
}
static struct ureg reserve_temp( struct tnl_program *p )
{
struct ureg temp = get_temp( p );
@ -437,6 +441,7 @@ static struct ureg reserve_temp( struct tnl_program *p )
return temp;
}
static void release_temp( struct tnl_program *p, struct ureg reg )
{
if (reg.file == PROGRAM_TEMPORARY) {
@ -493,6 +498,7 @@ static struct ureg register_input( struct tnl_program *p, GLuint input )
}
}
/**
* \param input one of VERT_RESULT_x tokens.
*/
@ -502,6 +508,7 @@ static struct ureg register_output( struct tnl_program *p, GLuint output )
return make_ureg(PROGRAM_OUTPUT, output);
}
static struct ureg register_const4f( struct tnl_program *p,
GLfloat s0,
GLfloat s1,
@ -531,6 +538,7 @@ static GLboolean is_undef( struct ureg reg )
return reg.file == PROGRAM_UNDEFINED;
}
static struct ureg get_identity_param( struct tnl_program *p )
{
if (is_undef(p->identity))
@ -571,6 +579,7 @@ static void emit_arg( struct prog_src_register *src,
ASSERT(src->Index == reg.idx);
}
static void emit_dst( struct prog_dst_register *dst,
struct ureg reg, GLuint mask )
{
@ -586,6 +595,7 @@ static void emit_dst( struct prog_dst_register *dst,
ASSERT(dst->Index == reg.idx);
}
static void debug_insn( struct prog_instruction *inst, const char *fn,
GLuint line )
{
@ -696,6 +706,7 @@ static void emit_matrix_transform_vec4( struct tnl_program *p,
emit_op2(p, OPCODE_DP4, dest, WRITEMASK_W, src, mat[3]);
}
/* This version is much easier to implement if writemasks are not
* supported natively on the target or (like SSE), the target doesn't
* have a clean/obvious dotproduct implementation.
@ -721,6 +732,7 @@ static void emit_transpose_matrix_transform_vec4( struct tnl_program *p,
release_temp(p, tmp);
}
static void emit_matrix_transform_vec3( struct tnl_program *p,
struct ureg dest,
const struct ureg *mat,
@ -748,6 +760,7 @@ static void emit_normalize_vec3( struct tnl_program *p,
#endif
}
static void emit_passthrough( struct tnl_program *p,
GLuint input,
GLuint output )
@ -756,6 +769,7 @@ static void emit_passthrough( struct tnl_program *p,
emit_op1(p, OPCODE_MOV, out, 0, register_input(p, input));
}
static struct ureg get_eye_position( struct tnl_program *p )
{
if (is_undef(p->eye_position)) {
@ -803,7 +817,6 @@ static struct ureg get_eye_position_z( struct tnl_program *p )
}
static struct ureg get_eye_position_normalized( struct tnl_program *p )
{
if (is_undef(p->eye_position_normalized)) {
@ -865,7 +878,6 @@ static struct ureg get_transformed_normal( struct tnl_program *p )
}
static void build_hpos( struct tnl_program *p )
{
struct ureg pos = register_input( p, VERT_ATTRIB_POS );
@ -891,7 +903,9 @@ static GLuint material_attrib( GLuint side, GLuint property )
side);
}
/* Get a bitmask of which material values vary on a per-vertex basis.
/**
* Get a bitmask of which material values vary on a per-vertex basis.
*/
static void set_material_flags( struct tnl_program *p )
{
@ -927,7 +941,9 @@ static struct ureg get_material( struct tnl_program *p, GLuint side,
MAT_BIT_FRONT_AMBIENT | \
MAT_BIT_FRONT_DIFFUSE) << (side))
/* Either return a precalculated constant value or emit code to
/**
* Either return a precalculated constant value or emit code to
* calculate these values dynamically in the case where material calls
* are present between begin/end pairs.
*
@ -970,6 +986,7 @@ static struct ureg get_lightprod( struct tnl_program *p, GLuint light,
return register_param4(p, STATE_LIGHTPROD, light, side, property);
}
static struct ureg calculate_light_attenuation( struct tnl_program *p,
GLuint i,
struct ureg VPpli,
@ -1226,7 +1243,6 @@ static void build_lighting( struct tnl_program *p )
struct ureg res0, res1;
GLuint mask0, mask1;
if (count == nr_lights) {
if (separate) {
mask0 = WRITEMASK_XYZ;
@ -1247,7 +1263,6 @@ static void build_lighting( struct tnl_program *p )
res1 = _col1;
}
if (!is_undef(att)) {
/* light is attenuated by distance */
emit_op1(p, OPCODE_LIT, lit, 0, dots);
@ -1320,7 +1335,6 @@ static void build_lighting( struct tnl_program *p )
emit_op3(p, OPCODE_MAD, res0, mask0, swizzle1(lit,Y), diffuse, _bfc0);
emit_op3(p, OPCODE_MAD, res1, mask1, swizzle1(lit,Z), specular, _bfc1);
/* restore negate flag for next lighting */
dots = negate(dots);
@ -1395,6 +1409,7 @@ static void build_fog( struct tnl_program *p )
emit_op1(p, useabs ? OPCODE_ABS : OPCODE_MOV, fog, WRITEMASK_X, input);
}
}
static void build_reflect_texgen( struct tnl_program *p,
struct ureg dest,
@ -1414,6 +1429,7 @@ static void build_reflect_texgen( struct tnl_program *p,
release_temp(p, tmp);
}
static void build_sphere_texgen( struct tnl_program *p,
struct ureg dest,
GLuint writemask )
@ -1461,7 +1477,7 @@ static void build_texture_transform( struct tnl_program *p )
{
GLuint i, j;
for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
if (!(p->state->fragprog_inputs_read & FRAG_BIT_TEX(i)))
continue;
@ -1524,10 +1540,8 @@ static void build_texture_transform( struct tnl_program *p )
case TXG_NONE:
copy_mask |= WRITEMASK_X << j;
}
}
if (sphere_mask) {
build_sphere_texgen(p, out_texgen, sphere_mask);
}
@ -1610,6 +1624,7 @@ static void build_atten_pointsize( struct tnl_program *p )
release_temp(p, ut);
}
/**
* Emit constant point size.
*/
@ -1620,6 +1635,7 @@ static void build_constant_pointsize( struct tnl_program *p )
emit_op1(p, OPCODE_MOV, out, WRITEMASK_X, state_size);
}
/**
* Pass-though per-vertex point size, from user's point size array.
*/

View file

@ -289,7 +289,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.depthBits);
break;
case GL_DEPTH_CLEAR_VALUE:
params[0] = FLOAT_TO_BOOLEAN(ctx->Depth.Clear);
params[0] = FLOAT_TO_BOOLEAN(((GLfloat) ctx->Depth.Clear));
break;
case GL_DEPTH_FUNC:
params[0] = ENUM_TO_BOOLEAN(ctx->Depth.Func);
@ -2137,7 +2137,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
params[0] = (GLfloat)(ctx->DrawBuffer->Visual.depthBits);
break;
case GL_DEPTH_CLEAR_VALUE:
params[0] = ctx->Depth.Clear;
params[0] = ((GLfloat) ctx->Depth.Clear);
break;
case GL_DEPTH_FUNC:
params[0] = ENUM_TO_FLOAT(ctx->Depth.Func);
@ -3985,7 +3985,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
params[0] = ctx->DrawBuffer->Visual.depthBits;
break;
case GL_DEPTH_CLEAR_VALUE:
params[0] = FLOAT_TO_INT(ctx->Depth.Clear);
params[0] = FLOAT_TO_INT(((GLfloat) ctx->Depth.Clear));
break;
case GL_DEPTH_FUNC:
params[0] = ENUM_TO_INT(ctx->Depth.Func);

View file

@ -180,7 +180,7 @@ StateVars = [
( "GL_DEPTH_BIAS", GLfloat, ["ctx->Pixel.DepthBias"], "", None ),
( "GL_DEPTH_BITS", GLint, ["ctx->DrawBuffer->Visual.depthBits"],
"", None ),
( "GL_DEPTH_CLEAR_VALUE", GLfloatN, ["ctx->Depth.Clear"], "", None ),
( "GL_DEPTH_CLEAR_VALUE", GLfloatN, ["((GLfloat) ctx->Depth.Clear)"], "", None ),
( "GL_DEPTH_FUNC", GLenum, ["ctx->Depth.Func"], "", None ),
( "GL_DEPTH_RANGE", GLfloatN,
[ "ctx->Viewport.Near", "ctx->Viewport.Far" ], "", None ),

View file

@ -61,7 +61,7 @@
/**
* \return GL_TRUE if type is packed pixel type, GL_FALSE otherwise.
*/
static GLboolean
GLboolean
_mesa_type_is_packed(GLenum type)
{
switch (type) {

View file

@ -36,6 +36,9 @@ _mesa_swap2( GLushort *p, GLuint n );
extern void
_mesa_swap4( GLuint *p, GLuint n );
extern GLboolean
_mesa_type_is_packed(GLenum type);
extern GLint
_mesa_sizeof_type( GLenum type );

View file

@ -930,6 +930,18 @@ _mesa_sprintf( char *str, const char *fmt, ... )
return r;
}
/** Wrapper around vsnprintf() */
int
_mesa_snprintf( char *str, size_t size, const char *fmt, ... )
{
int r;
va_list args;
va_start( args, fmt );
r = vsnprintf( str, size, fmt, args );
va_end( args );
return r;
}
/** Wrapper around printf(), using vsprintf() for the formatting. */
void
_mesa_printf( const char *fmtString, ... )

View file

@ -763,6 +763,9 @@ _mesa_strtod( const char *s, char **end );
extern int
_mesa_sprintf( char *str, const char *fmt, ... );
extern int
_mesa_snprintf( char *str, size_t size, const char *fmt, ... );
extern void
_mesa_printf( const char *fmtString, ... );

View file

@ -41,7 +41,11 @@ bytes_per_pixel(GLenum datatype, GLuint comps)
{
GLint b = _mesa_sizeof_packed_type(datatype);
assert(b >= 0);
return b * comps;
if (_mesa_type_is_packed(datatype))
return b;
else
return b * comps;
}

View file

@ -1,15 +1,9 @@
/**
* \file mtypes.h
* Main Mesa data structures.
*
* Please try to mark derived values with a leading underscore ('_').
*/
/*
* Mesa 3-D graphics library
* Version: 7.3
*
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2008 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@ -29,7 +23,12 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file mtypes.h
* Main Mesa data structures.
*
* Please try to mark derived values with a leading underscore ('_').
*/
#ifndef TYPES_H
#define TYPES_H
@ -641,7 +640,7 @@ struct gl_current_attrib
GLfloat RasterColor[4];
GLfloat RasterSecondaryColor[4];
GLfloat RasterIndex;
GLfloat RasterTexCoords[MAX_TEXTURE_COORD_UNITS][4];
GLfloat RasterTexCoords[MAX_TEXTURE_UNITS][4];
GLboolean RasterPosValid;
/*@}*/
};
@ -725,10 +724,10 @@ struct gl_enable_attrib
GLboolean SampleCoverage; /* GL_ARB_multisample */
GLboolean SampleCoverageInvert; /* GL_ARB_multisample */
GLboolean RasterPositionUnclipped; /* GL_IBM_rasterpos_clip */
GLuint Texture[MAX_TEXTURE_IMAGE_UNITS];
GLuint TexGen[MAX_TEXTURE_COORD_UNITS];
GLuint Texture[MAX_TEXTURE_UNITS];
GLuint TexGen[MAX_TEXTURE_UNITS];
/* SGI_texture_color_table */
GLboolean TextureColorTable[MAX_TEXTURE_IMAGE_UNITS];
GLboolean TextureColorTable[MAX_TEXTURE_UNITS];
/* GL_ARB_vertex_program / GL_NV_vertex_program */
GLboolean VertexProgram;
GLboolean VertexProgramPointSize;
@ -1071,7 +1070,7 @@ struct gl_point_attrib
GLfloat Threshold; /**< GL_EXT_point_parameters */
GLboolean _Attenuated; /**< True if Params != [1, 0, 0] */
GLboolean PointSprite; /**< GL_NV/ARB_point_sprite */
GLboolean CoordReplace[MAX_TEXTURE_COORD_UNITS]; /**< GL_ARB_point_sprite */
GLboolean CoordReplace[MAX_TEXTURE_UNITS]; /**< GL_ARB_point_sprite */
GLenum SpriteRMode; /**< GL_NV_point_sprite (only!) */
GLenum SpriteOrigin; /**< GL_ARB_point_sprite */
};
@ -1559,7 +1558,7 @@ struct gl_texture_attrib
* name multitexture
*/
/**@{*/
GLuint CurrentUnit; /**< Active texture unit */
GLuint CurrentUnit; /**< Active texture unit [0, MaxTextureImageUnits-1] */
GLbitfield _EnabledUnits; /**< one bit set for each really-enabled unit */
GLbitfield _EnabledCoordUnits; /**< one bit per enabled coordinate unit */
GLbitfield _GenFlags; /**< for texgen */
@ -1876,7 +1875,7 @@ struct gl_program
GLbitfield OutputsWritten; /**< Bitmask of which output regs are written to */
GLbitfield InputFlags[MAX_PROGRAM_INPUTS]; /**< PROG_PARAM_BIT_x flags */
GLbitfield OutputFlags[MAX_PROGRAM_OUTPUTS]; /**< PROG_PARAM_BIT_x flags */
GLbitfield TexturesUsed[MAX_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_BIT bitmask */
GLbitfield TexturesUsed[MAX_TEXTURE_UNITS]; /**< TEXTURE_x_BIT bitmask */
GLbitfield SamplersUsed; /**< Bitfield of which samplers are used */
GLbitfield ShadowSamplers; /**< Texture units used for shadow sampling. */
@ -2473,9 +2472,9 @@ struct gl_constants
GLint MaxTextureRectSize; /* GL_NV_texture_rectangle */
GLuint MaxTextureCoordUnits;
GLuint MaxTextureImageUnits;
GLuint MaxTextureUnits; /* = MIN(CoordUnits, ImageUnits) */
GLfloat MaxTextureMaxAnisotropy; /* GL_EXT_texture_filter_anisotropic */
GLfloat MaxTextureLodBias; /* GL_EXT_texture_lod_bias */
GLuint MaxTextureUnits; /**< = MIN(CoordUnits, ImageUnits) */
GLfloat MaxTextureMaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */
GLfloat MaxTextureLodBias; /**< GL_EXT_texture_lod_bias */
GLuint MaxArrayLockSize;
GLint SubPixelBits;
GLfloat MinPointSize, MaxPointSize; /* aliased */
@ -2951,7 +2950,7 @@ struct __GLcontextRec
struct gl_matrix_stack ModelviewMatrixStack;
struct gl_matrix_stack ProjectionMatrixStack;
struct gl_matrix_stack ColorMatrixStack;
struct gl_matrix_stack TextureMatrixStack[MAX_TEXTURE_COORD_UNITS];
struct gl_matrix_stack TextureMatrixStack[MAX_TEXTURE_UNITS];
struct gl_matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES];
struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks */
/*@}*/

View file

@ -257,7 +257,7 @@ _mesa_init_point(GLcontext *ctx)
ctx->Point.PointSprite = GL_FALSE; /* GL_ARB/NV_point_sprite */
ctx->Point.SpriteRMode = GL_ZERO; /* GL_NV_point_sprite (only!) */
ctx->Point.SpriteOrigin = GL_UPPER_LEFT; /* GL_ARB_point_sprite */
for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
ctx->Point.CoordReplace[i] = GL_FALSE; /* GL_ARB/NV_point_sprite */
}
}

View file

@ -500,7 +500,7 @@ void _mesa_init_rastpos( GLcontext * ctx )
ASSIGN_4V( ctx->Current.RasterColor, 1.0, 1.0, 1.0, 1.0 );
ASSIGN_4V( ctx->Current.RasterSecondaryColor, 0.0, 0.0, 0.0, 1.0 );
ctx->Current.RasterIndex = 1.0;
for (i=0; i<MAX_TEXTURE_UNITS; i++)
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++)
ASSIGN_4V( ctx->Current.RasterTexCoords[i], 0.0, 0.0, 0.0, 1.0 );
ctx->Current.RasterPosValid = GL_TRUE;
}

View file

@ -38,6 +38,21 @@
#include "texenvprogram.h"
/*
* Note on texture units:
*
* The number of texture units supported by fixed-function fragment
* processing is MAX_TEXTURE_COORD_UNITS, not MAX_TEXTURE_IMAGE_UNITS.
* That's because there's a one-to-one correspondence between texture
* coordinates and samplers in fixed-function processing.
*
* Since fixed-function vertex processing is limited to MAX_TEXTURE_COORD_UNITS
* sets of texcoords, so is fixed-function fragment processing.
*
* We can safely use ctx->Const.MaxTextureUnits for loop bounds.
*/
struct texenvprog_cache_item
{
GLuint hash;
@ -50,13 +65,13 @@ struct texenvprog_cache_item
/**
* Up to nine instructions per tex unit, plus fog, specular color.
*/
#define MAX_INSTRUCTIONS ((MAX_TEXTURE_UNITS * 9) + 12)
#define MAX_INSTRUCTIONS ((MAX_TEXTURE_COORD_UNITS * 9) + 12)
#define DISASSEM (MESA_VERBOSE & VERBOSE_DISASSEM)
struct mode_opt {
GLubyte Source:4;
GLubyte Operand:3;
GLuint Source:4;
GLuint Operand:3;
};
struct state_key {
@ -313,7 +328,7 @@ static void make_state_key( GLcontext *ctx, struct state_key *key )
memset(key, 0, sizeof(*key));
for (i=0;i<MAX_TEXTURE_UNITS;i++) {
for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
GLenum format;
@ -416,7 +431,7 @@ struct texenv_fragment_program {
GLbitfield temp_in_use; /**< Tracks temporary regs which are in use. */
GLboolean error;
struct ureg src_texture[MAX_TEXTURE_UNITS];
struct ureg src_texture[MAX_TEXTURE_COORD_UNITS];
/* Reg containing each texture unit's sampled texture color,
* else undef.
*/
@ -1201,7 +1216,7 @@ create_new_program(GLcontext *ctx, struct state_key *key,
p.program->Base.InputsRead = 0;
p.program->Base.OutputsWritten = 1 << FRAG_RESULT_COLR;
for (unit = 0; unit < MAX_TEXTURE_UNITS; unit++)
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++)
p.src_texture[unit] = undef;
p.src_previous = undef;

View file

@ -1685,7 +1685,7 @@ _mesa_format_to_type_and_comps(const struct gl_texture_format *format,
case MESA_FORMAT_ARGB1555:
case MESA_FORMAT_ARGB1555_REV:
*datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV;
*comps = 3;
*comps = 4;
return;
case MESA_FORMAT_AL88:

View file

@ -49,6 +49,14 @@ texture_get_row(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
trb->TexImage->FetchTexelc(trb->TexImage, x + i, y, z, rgbaOut + 4 * i);
}
}
else if (rb->DataType == GL_UNSIGNED_SHORT) {
GLushort *zValues = (GLushort *) values;
for (i = 0; i < count; i++) {
GLfloat flt;
trb->TexImage->FetchTexelf(trb->TexImage, x + i, y, z, &flt);
zValues[i] = (GLushort) (flt * 0xffff);
}
}
else if (rb->DataType == GL_UNSIGNED_INT) {
GLuint *zValues = (GLuint *) values;
/*
@ -96,6 +104,15 @@ texture_get_values(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
z, rgbaOut + 4 * i);
}
}
else if (rb->DataType == GL_UNSIGNED_SHORT) {
GLushort *zValues = (GLushort *) values;
for (i = 0; i < count; i++) {
GLfloat flt;
trb->TexImage->FetchTexelf(trb->TexImage, x[i], y[i] + trb->Yoffset,
z, &flt);
zValues[i] = (GLushort) (flt * 0xffff);
}
}
else if (rb->DataType == GL_UNSIGNED_INT) {
GLuint *zValues = (GLuint *) values;
for (i = 0; i < count; i++) {
@ -147,6 +164,14 @@ texture_put_row(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
rgba += 4;
}
}
else if (rb->DataType == GL_UNSIGNED_SHORT) {
const GLushort *zValues = (const GLushort *) values;
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
trb->Store(trb->TexImage, x + i, y, z, zValues + i);
}
}
}
else if (rb->DataType == GL_UNSIGNED_INT) {
const GLuint *zValues = (const GLuint *) values;
for (i = 0; i < count; i++) {
@ -189,6 +214,14 @@ texture_put_mono_row(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
}
}
}
else if (rb->DataType == GL_UNSIGNED_SHORT) {
const GLushort zValue = *((const GLushort *) value);
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
trb->Store(trb->TexImage, x + i, y, z, &zValue);
}
}
}
else if (rb->DataType == GL_UNSIGNED_INT) {
const GLuint zValue = *((const GLuint *) value);
for (i = 0; i < count; i++) {
@ -231,12 +264,19 @@ texture_put_values(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
rgba += 4;
}
}
else if (rb->DataType == GL_UNSIGNED_SHORT) {
const GLushort *zValues = (const GLushort *) values;
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, zValues + i);
}
}
}
else if (rb->DataType == GL_UNSIGNED_INT) {
const GLuint *zValues = (const GLuint *) values;
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z,
zValues + i);
trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, zValues + i);
}
}
}
@ -281,6 +321,14 @@ texture_put_mono_values(GLcontext *ctx, struct gl_renderbuffer *rb,
}
}
}
else if (rb->DataType == GL_UNSIGNED_SHORT) {
const GLushort zValue = *((const GLushort *) value);
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &zValue);
}
}
}
else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) {
const GLuint zValue = *((const GLuint *) value);
const GLfloat flt = (GLfloat) ((zValue >> 8) * (1.0 / 0xffffff));

View file

@ -81,7 +81,7 @@ _mesa_copy_texture_state( const GLcontext *src, GLcontext *dst )
dst->Texture.SharedPalette = src->Texture.SharedPalette;
/* per-unit state */
for (i = 0; i < src->Const.MaxTextureUnits; i++) {
for (i = 0; i < src->Const.MaxTextureImageUnits; i++) {
dst->Texture.Unit[i].Enabled = src->Texture.Unit[i].Enabled;
dst->Texture.Unit[i].EnvMode = src->Texture.Unit[i].EnvMode;
COPY_4V(dst->Texture.Unit[i].EnvColor, src->Texture.Unit[i].EnvColor);
@ -307,8 +307,7 @@ _mesa_ActiveTextureARB(GLenum texture)
_mesa_debug(ctx, "glActiveTexture %s\n",
_mesa_lookup_enum_by_nr(texture));
/* XXX error-check against max(coordunits, imageunits) */
if (texUnit >= ctx->Const.MaxTextureUnits) {
if (texUnit >= ctx->Const.MaxTextureImageUnits) {
_mesa_error(ctx, GL_INVALID_ENUM, "glActiveTexture(texture)");
return;
}
@ -369,7 +368,7 @@ update_texture_matrices( GLcontext *ctx )
ctx->Texture._TexMatEnabled = 0;
for (i=0; i < ctx->Const.MaxTextureUnits; i++) {
for (i=0; i < ctx->Const.MaxTextureCoordUnits; i++) {
if (_math_matrix_is_dirty(ctx->TextureMatrixStack[i].Top)) {
_math_matrix_analyse( ctx->TextureMatrixStack[i].Top );
@ -491,7 +490,7 @@ update_texture_state( GLcontext *ctx )
/*
* Update texture unit state.
*/
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
for (unit = 0; unit < ctx->Const.MaxTextureImageUnits; unit++) {
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
GLbitfield enableBits;
@ -621,7 +620,7 @@ update_texture_state( GLcontext *ctx )
}
/* Setup texgen for those texture coordinate sets that are in use */
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
for (unit = 0; unit < ctx->Const.MaxTextureCoordUnits; unit++) {
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
if (!(ctx->Texture._EnabledCoordUnits & (1 << unit)))

View file

@ -290,7 +290,8 @@ _mesa_use_uniform(struct gl_program_parameter_list *paramList,
GLuint i;
for (i = 0; i < paramList->NumParameters; i++) {
struct gl_program_parameter *p = paramList->Parameters + i;
if (p->Type == PROGRAM_UNIFORM && _mesa_strcmp(p->Name, name) == 0) {
if ((p->Type == PROGRAM_UNIFORM || p->Type == PROGRAM_SAMPLER) &&
_mesa_strcmp(p->Name, name) == 0) {
p->Used = GL_TRUE;
/* Note that large uniforms may occupy several slots so we're
* not done searching yet.

View file

@ -79,10 +79,10 @@ typedef enum gl_state_index_ {
STATE_SHININESS,
STATE_HALF_VECTOR,
STATE_POSITION,
STATE_ATTENUATION,
STATE_SPOT_DIRECTION,
STATE_SPOT_CUTOFF,
STATE_POSITION, /**< xyzw = position */
STATE_ATTENUATION, /**< xyz = attenuation, w = spot exponent */
STATE_SPOT_DIRECTION, /**< xyz = direction, w = cos(cutoff) */
STATE_SPOT_CUTOFF, /**< x = cutoff, yzw = undefined */
STATE_TEXGEN_EYE_S,
STATE_TEXGEN_EYE_T,

View file

@ -1,8 +1,9 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Version: 7.3
*
* Copyright (C) 2006 Brian Paul All Rights Reserved.
* Copyright (C) 2008 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@ -26,8 +27,9 @@
// From Shader Spec, ver. 1.10, rev. 59
//
//bp: XXX these will probably go away since the value needs to be
//determined at runtime and may vary from one GLcontext to another...
// Note: the values assigned to these constants here aren't actually used.
// They're set by the compiler according to the GL context limits.
// See slang_simplify.c
const int gl_MaxLights = 8;
const int gl_MaxClipPlanes = 6;
const int gl_MaxTextureUnits = 8;
@ -98,6 +100,9 @@ struct gl_MaterialParameters {
uniform gl_MaterialParameters gl_FrontMaterial;
uniform gl_MaterialParameters gl_BackMaterial;
/* NOTE: the order of these fields is significant!
* See the definition of the lighting state vars such as STATE_SPOT_DIRECTION.
*/
struct gl_LightSourceParameters {
vec4 ambient;
vec4 diffuse;
@ -105,12 +110,14 @@ struct gl_LightSourceParameters {
vec4 position;
vec4 halfVector;
vec3 spotDirection;
float spotExponent;
float spotCutoff;
float spotCosCutoff;
float constantAttenuation;
float linearAttenuation;
float quadraticAttenuation;
float spotExponent;
float spotCutoff;
};
uniform gl_LightSourceParameters gl_LightSource[gl_MaxLights];

View file

@ -66,58 +66,58 @@
116,83,111,117,114,99,101,80,97,114,97,109,101,116,101,114,115,0,12,0,97,109,98,105,101,110,116,0,
0,0,1,12,0,100,105,102,102,117,115,101,0,0,0,1,12,0,115,112,101,99,117,108,97,114,0,0,0,1,12,0,112,
111,115,105,116,105,111,110,0,0,0,1,12,0,104,97,108,102,86,101,99,116,111,114,0,0,0,1,11,0,115,112,
111,116,68,105,114,101,99,116,105,111,110,0,0,0,1,9,0,115,112,111,116,69,120,112,111,110,101,110,
116,0,0,0,1,9,0,115,112,111,116,67,117,116,111,102,102,0,0,0,1,9,0,115,112,111,116,67,111,115,67,
117,116,111,102,102,0,0,0,1,9,0,99,111,110,115,116,97,110,116,65,116,116,101,110,117,97,116,105,
111,110,0,0,0,1,9,0,108,105,110,101,97,114,65,116,116,101,110,117,97,116,105,111,110,0,0,0,1,9,0,
113,117,97,100,114,97,116,105,99,65,116,116,101,110,117,97,116,105,111,110,0,0,0,0,0,0,0,2,2,90,95,
4,0,25,103,108,95,76,105,103,104,116,83,111,117,114,99,101,80,97,114,97,109,101,116,101,114,115,0,
0,1,103,108,95,76,105,103,104,116,83,111,117,114,99,101,0,3,18,103,108,95,77,97,120,76,105,103,104,
116,115,0,0,0,2,2,90,95,0,0,24,103,108,95,76,105,103,104,116,77,111,100,101,108,80,97,114,97,109,
101,116,101,114,115,0,12,0,97,109,98,105,101,110,116,0,0,0,0,0,0,0,2,2,90,95,4,0,25,103,108,95,76,
105,103,104,116,77,111,100,101,108,80,97,114,97,109,101,116,101,114,115,0,0,1,103,108,95,76,105,
103,104,116,77,111,100,101,108,0,0,0,2,2,90,95,0,0,24,103,108,95,76,105,103,104,116,77,111,100,101,
108,80,114,111,100,117,99,116,115,0,12,0,115,99,101,110,101,67,111,108,111,114,0,0,0,0,0,0,0,2,2,
90,95,4,0,25,103,108,95,76,105,103,104,116,77,111,100,101,108,80,114,111,100,117,99,116,115,0,0,1,
103,108,95,70,114,111,110,116,76,105,103,104,116,77,111,100,101,108,80,114,111,100,117,99,116,0,0,
0,2,2,90,95,4,0,25,103,108,95,76,105,103,104,116,77,111,100,101,108,80,114,111,100,117,99,116,115,
0,0,1,103,108,95,66,97,99,107,76,105,103,104,116,77,111,100,101,108,80,114,111,100,117,99,116,0,0,
0,2,2,90,95,0,0,24,103,108,95,76,105,103,104,116,80,114,111,100,117,99,116,115,0,12,0,97,109,98,
105,101,110,116,0,0,0,1,12,0,100,105,102,102,117,115,101,0,0,0,1,12,0,115,112,101,99,117,108,97,
114,0,0,0,0,0,0,0,2,2,90,95,4,0,25,103,108,95,76,105,103,104,116,80,114,111,100,117,99,116,115,0,0,
1,103,108,95,70,114,111,110,116,76,105,103,104,116,80,114,111,100,117,99,116,0,3,18,103,108,95,77,
97,120,76,105,103,104,116,115,0,0,0,2,2,90,95,4,0,25,103,108,95,76,105,103,104,116,80,114,111,100,
117,99,116,115,0,0,1,103,108,95,66,97,99,107,76,105,103,104,116,80,114,111,100,117,99,116,0,3,18,
103,108,95,77,97,120,76,105,103,104,116,115,0,0,0,2,2,90,95,4,0,12,0,1,103,108,95,84,101,120,116,
117,114,101,69,110,118,67,111,108,111,114,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,
73,109,97,103,101,85,110,105,116,115,0,0,0,2,2,90,95,4,0,12,0,1,103,108,95,69,121,101,80,108,97,
111,116,68,105,114,101,99,116,105,111,110,0,0,0,1,9,0,115,112,111,116,67,111,115,67,117,116,111,
102,102,0,0,0,1,9,0,99,111,110,115,116,97,110,116,65,116,116,101,110,117,97,116,105,111,110,0,0,0,
1,9,0,108,105,110,101,97,114,65,116,116,101,110,117,97,116,105,111,110,0,0,0,1,9,0,113,117,97,100,
114,97,116,105,99,65,116,116,101,110,117,97,116,105,111,110,0,0,0,1,9,0,115,112,111,116,69,120,112,
111,110,101,110,116,0,0,0,1,9,0,115,112,111,116,67,117,116,111,102,102,0,0,0,0,0,0,0,2,2,90,95,4,0,
25,103,108,95,76,105,103,104,116,83,111,117,114,99,101,80,97,114,97,109,101,116,101,114,115,0,0,1,
103,108,95,76,105,103,104,116,83,111,117,114,99,101,0,3,18,103,108,95,77,97,120,76,105,103,104,116,
115,0,0,0,2,2,90,95,0,0,24,103,108,95,76,105,103,104,116,77,111,100,101,108,80,97,114,97,109,101,
116,101,114,115,0,12,0,97,109,98,105,101,110,116,0,0,0,0,0,0,0,2,2,90,95,4,0,25,103,108,95,76,105,
103,104,116,77,111,100,101,108,80,97,114,97,109,101,116,101,114,115,0,0,1,103,108,95,76,105,103,
104,116,77,111,100,101,108,0,0,0,2,2,90,95,0,0,24,103,108,95,76,105,103,104,116,77,111,100,101,108,
80,114,111,100,117,99,116,115,0,12,0,115,99,101,110,101,67,111,108,111,114,0,0,0,0,0,0,0,2,2,90,95,
4,0,25,103,108,95,76,105,103,104,116,77,111,100,101,108,80,114,111,100,117,99,116,115,0,0,1,103,
108,95,70,114,111,110,116,76,105,103,104,116,77,111,100,101,108,80,114,111,100,117,99,116,0,0,0,2,
2,90,95,4,0,25,103,108,95,76,105,103,104,116,77,111,100,101,108,80,114,111,100,117,99,116,115,0,0,
1,103,108,95,66,97,99,107,76,105,103,104,116,77,111,100,101,108,80,114,111,100,117,99,116,0,0,0,2,
2,90,95,0,0,24,103,108,95,76,105,103,104,116,80,114,111,100,117,99,116,115,0,12,0,97,109,98,105,
101,110,116,0,0,0,1,12,0,100,105,102,102,117,115,101,0,0,0,1,12,0,115,112,101,99,117,108,97,114,0,
0,0,0,0,0,0,2,2,90,95,4,0,25,103,108,95,76,105,103,104,116,80,114,111,100,117,99,116,115,0,0,1,103,
108,95,70,114,111,110,116,76,105,103,104,116,80,114,111,100,117,99,116,0,3,18,103,108,95,77,97,120,
76,105,103,104,116,115,0,0,0,2,2,90,95,4,0,25,103,108,95,76,105,103,104,116,80,114,111,100,117,99,
116,115,0,0,1,103,108,95,66,97,99,107,76,105,103,104,116,80,114,111,100,117,99,116,0,3,18,103,108,
95,77,97,120,76,105,103,104,116,115,0,0,0,2,2,90,95,4,0,12,0,1,103,108,95,84,101,120,116,117,114,
101,69,110,118,67,111,108,111,114,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,73,109,97,
103,101,85,110,105,116,115,0,0,0,2,2,90,95,4,0,12,0,1,103,108,95,69,121,101,80,108,97,110,101,83,0,
3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,111,114,100,115,0,0,0,2,2,90,95,4,0,12,
0,1,103,108,95,69,121,101,80,108,97,110,101,84,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,
101,67,111,111,114,100,115,0,0,0,2,2,90,95,4,0,12,0,1,103,108,95,69,121,101,80,108,97,110,101,82,0,
3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,111,114,100,115,0,0,0,2,2,90,95,4,0,12,
0,1,103,108,95,69,121,101,80,108,97,110,101,81,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,
101,67,111,111,114,100,115,0,0,0,2,2,90,95,4,0,12,0,1,103,108,95,79,98,106,101,99,116,80,108,97,
110,101,83,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,111,114,100,115,0,0,0,2,2,
90,95,4,0,12,0,1,103,108,95,69,121,101,80,108,97,110,101,84,0,3,18,103,108,95,77,97,120,84,101,120,
116,117,114,101,67,111,111,114,100,115,0,0,0,2,2,90,95,4,0,12,0,1,103,108,95,69,121,101,80,108,97,
110,101,82,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,111,114,100,115,0,0,0,2,2,
90,95,4,0,12,0,1,103,108,95,69,121,101,80,108,97,110,101,81,0,3,18,103,108,95,77,97,120,84,101,120,
116,117,114,101,67,111,111,114,100,115,0,0,0,2,2,90,95,4,0,12,0,1,103,108,95,79,98,106,101,99,116,
80,108,97,110,101,83,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,111,114,100,115,
0,0,0,2,2,90,95,4,0,12,0,1,103,108,95,79,98,106,101,99,116,80,108,97,110,101,84,0,3,18,103,108,95,
77,97,120,84,101,120,116,117,114,101,67,111,111,114,100,115,0,0,0,2,2,90,95,4,0,12,0,1,103,108,95,
79,98,106,101,99,116,80,108,97,110,101,82,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,
67,111,111,114,100,115,0,0,0,2,2,90,95,4,0,12,0,1,103,108,95,79,98,106,101,99,116,80,108,97,110,
101,81,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,111,114,100,115,0,0,0,2,2,90,
95,0,0,24,103,108,95,70,111,103,80,97,114,97,109,101,116,101,114,115,0,12,0,99,111,108,111,114,0,0,
0,1,9,0,100,101,110,115,105,116,121,0,0,0,1,9,0,115,116,97,114,116,0,0,0,1,9,0,101,110,100,0,0,0,1,
9,0,115,99,97,108,101,0,0,0,0,0,0,0,2,2,90,95,4,0,25,103,108,95,70,111,103,80,97,114,97,109,101,
116,101,114,115,0,0,1,103,108,95,70,111,103,0,0,0,1,90,95,0,0,9,0,0,114,97,100,105,97,110,115,0,1,
1,0,0,9,0,100,101,103,0,0,0,1,3,2,90,95,1,0,9,0,1,99,0,2,17,51,0,49,52,49,53,57,50,54,0,0,17,49,56,
48,0,48,0,0,49,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,
108,0,0,18,100,101,103,0,0,18,99,0,0,0,0,1,90,95,0,0,10,0,0,114,97,100,105,97,110,115,0,1,1,0,0,10,
0,100,101,103,0,0,0,1,3,2,90,95,1,0,9,0,1,99,0,2,17,51,0,49,52,49,53,57,50,54,0,0,17,49,56,48,0,48,
0,0,49,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,
59,120,121,0,0,18,100,101,103,0,59,120,121,0,0,18,99,0,59,120,120,0,0,0,0,1,90,95,0,0,11,0,0,114,
97,100,105,97,110,115,0,1,1,0,0,11,0,100,101,103,0,0,0,1,3,2,90,95,1,0,9,0,1,99,0,2,17,51,0,49,52,
49,53,57,50,54,0,0,17,49,56,48,0,48,0,0,49,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,
0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,100,101,103,0,59,120,121,122,0,0,18,99,0,
59,120,120,120,0,0,0,0,1,90,95,0,0,12,0,0,114,97,100,105,97,110,115,0,1,1,0,0,12,0,100,101,103,0,0,
0,1,3,2,90,95,1,0,9,0,1,99,0,2,17,51,0,49,52,49,53,57,50,54,0,0,17,49,56,48,0,48,0,0,49,0,0,4,118,
90,95,4,0,12,0,1,103,108,95,79,98,106,101,99,116,80,108,97,110,101,84,0,3,18,103,108,95,77,97,120,
84,101,120,116,117,114,101,67,111,111,114,100,115,0,0,0,2,2,90,95,4,0,12,0,1,103,108,95,79,98,106,
101,99,116,80,108,97,110,101,82,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,111,
114,100,115,0,0,0,2,2,90,95,4,0,12,0,1,103,108,95,79,98,106,101,99,116,80,108,97,110,101,81,0,3,18,
103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,111,114,100,115,0,0,0,2,2,90,95,0,0,24,103,
108,95,70,111,103,80,97,114,97,109,101,116,101,114,115,0,12,0,99,111,108,111,114,0,0,0,1,9,0,100,
101,110,115,105,116,121,0,0,0,1,9,0,115,116,97,114,116,0,0,0,1,9,0,101,110,100,0,0,0,1,9,0,115,99,
97,108,101,0,0,0,0,0,0,0,2,2,90,95,4,0,25,103,108,95,70,111,103,80,97,114,97,109,101,116,101,114,
115,0,0,1,103,108,95,70,111,103,0,0,0,1,90,95,0,0,9,0,0,114,97,100,105,97,110,115,0,1,1,0,0,9,0,
100,101,103,0,0,0,1,3,2,90,95,1,0,9,0,1,99,0,2,17,51,0,49,52,49,53,57,50,54,0,0,17,49,56,48,0,48,0,
0,49,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,0,
18,100,101,103,0,0,18,99,0,0,0,0,1,90,95,0,0,10,0,0,114,97,100,105,97,110,115,0,1,1,0,0,10,0,100,
101,103,0,0,0,1,3,2,90,95,1,0,9,0,1,99,0,2,17,51,0,49,52,49,53,57,50,54,0,0,17,49,56,48,0,48,0,0,
49,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,59,
120,121,0,0,18,100,101,103,0,59,120,121,0,0,18,99,0,59,120,120,0,0,0,0,1,90,95,0,0,11,0,0,114,97,
100,105,97,110,115,0,1,1,0,0,11,0,100,101,103,0,0,0,1,3,2,90,95,1,0,9,0,1,99,0,2,17,51,0,49,52,49,
53,57,50,54,0,0,17,49,56,48,0,48,0,0,49,0,0,4,118,101,99,52,95,109,117,108,116,105,112,108,121,0,
18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,100,101,103,0,59,120,121,122,0,0,18,99,0,59,
120,120,120,0,0,0,0,1,90,95,0,0,12,0,0,114,97,100,105,97,110,115,0,1,1,0,0,12,0,100,101,103,0,0,0,
1,3,2,90,95,1,0,9,0,1,99,0,2,17,51,0,49,52,49,53,57,50,54,0,0,17,49,56,48,0,48,0,0,49,0,0,4,118,
101,99,52,95,109,117,108,116,105,112,108,121,0,18,95,95,114,101,116,86,97,108,0,0,18,100,101,103,0,
0,18,99,0,59,120,120,120,120,0,0,0,0,1,90,95,0,0,9,0,0,100,101,103,114,101,101,115,0,1,1,0,0,9,0,
114,97,100,0,0,0,1,3,2,90,95,1,0,9,0,1,99,0,2,17,49,56,48,0,48,0,0,17,51,0,49,52,49,53,57,50,54,0,

View file

@ -1,8 +1,9 @@
/*
* Mesa 3-D graphics library
* Version: 6.5.3
* Version: 7.3
*
* Copyright (C) 2005-2007 Brian Paul All Rights Reserved.
* Copyright (C) 2008 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@ -39,6 +40,10 @@
#include "shader/slang/slang_builtin.h"
/** special state token (see below) */
#define STATE_ARRAY ((gl_state_index) 0xfffff)
/**
* Lookup GL state given a variable name, 0, 1 or 2 indexes and a field.
* Allocate room for the state in the given param list and return position
@ -132,6 +137,8 @@ lookup_statevar(const char *var, GLint index1, GLint index2, const char *field,
}
}
else if (strcmp(var, "gl_ClipPlane") == 0) {
if (index1 < 0)
return -1;
tokens[0] = STATE_CLIPPLANE;
tokens[1] = index1;
}
@ -196,8 +203,12 @@ lookup_statevar(const char *var, GLint index1, GLint index2, const char *field,
}
}
else if (strcmp(var, "gl_LightSource") == 0) {
if (!field || index1 < 0)
return -1;
tokens[0] = STATE_LIGHT;
tokens[1] = index1;
if (strcmp(field, "ambient") == 0) {
tokens[2] = STATE_AMBIENT;
}
@ -272,6 +283,9 @@ lookup_statevar(const char *var, GLint index1, GLint index2, const char *field,
}
else if (strcmp(var, "gl_FrontLightProduct") == 0 ||
strcmp(var, "gl_BackLightProduct") == 0) {
if (index1 < 0 || !field)
return -1;
tokens[0] = STATE_LIGHTPROD;
tokens[1] = index1; /* light number */
if (strcmp(var, "gl_FrontLightProduct") == 0) {
@ -294,45 +308,63 @@ lookup_statevar(const char *var, GLint index1, GLint index2, const char *field,
}
}
else if (strcmp(var, "gl_TextureEnvColor") == 0) {
if (index1 < 0)
return -1;
tokens[0] = STATE_TEXENV_COLOR;
tokens[1] = index1;
}
else if (strcmp(var, "gl_EyePlaneS") == 0) {
if (index1 < 0)
return -1;
tokens[0] = STATE_TEXGEN;
tokens[1] = index1; /* tex unit */
tokens[2] = STATE_TEXGEN_EYE_S;
}
else if (strcmp(var, "gl_EyePlaneT") == 0) {
if (index1 < 0)
return -1;
tokens[0] = STATE_TEXGEN;
tokens[1] = index1; /* tex unit */
tokens[2] = STATE_TEXGEN_EYE_T;
}
else if (strcmp(var, "gl_EyePlaneR") == 0) {
if (index1 < 0)
return -1;
tokens[0] = STATE_TEXGEN;
tokens[1] = index1; /* tex unit */
tokens[2] = STATE_TEXGEN_EYE_R;
}
else if (strcmp(var, "gl_EyePlaneQ") == 0) {
if (index1 < 0)
return -1;
tokens[0] = STATE_TEXGEN;
tokens[1] = index1; /* tex unit */
tokens[2] = STATE_TEXGEN_EYE_Q;
}
else if (strcmp(var, "gl_ObjectPlaneS") == 0) {
if (index1 < 0)
return -1;
tokens[0] = STATE_TEXGEN;
tokens[1] = index1; /* tex unit */
tokens[2] = STATE_TEXGEN_OBJECT_S;
}
else if (strcmp(var, "gl_ObjectPlaneT") == 0) {
if (index1 < 0)
return -1;
tokens[0] = STATE_TEXGEN;
tokens[1] = index1; /* tex unit */
tokens[2] = STATE_TEXGEN_OBJECT_T;
}
else if (strcmp(var, "gl_ObjectPlaneR") == 0) {
if (index1 < 0)
return -1;
tokens[0] = STATE_TEXGEN;
tokens[1] = index1; /* tex unit */
tokens[2] = STATE_TEXGEN_OBJECT_R;
}
else if (strcmp(var, "gl_ObjectPlaneQ") == 0) {
if (index1 < 0)
return -1;
tokens[0] = STATE_TEXGEN;
tokens[1] = index1; /* tex unit */
tokens[2] = STATE_TEXGEN_OBJECT_Q;
@ -386,13 +418,222 @@ lookup_statevar(const char *var, GLint index1, GLint index2, const char *field,
}
/**
* Given a variable name and datatype, emit uniform/constant buffer
* entries which will store that state variable.
* For example, if name="gl_LightSource" we'll emit 64 state variable
* vectors/references and return position where that data starts. This will
* allow run-time array indexing into the light source array.
*
* Note that this is a recursive function.
*
* \return -1 if error, else index of start of data in the program parameter list
*/
static GLint
emit_statevars(const char *name, int array_len,
const slang_type_specifier *type,
gl_state_index tokens[STATE_LENGTH],
struct gl_program_parameter_list *paramList)
{
if (type->type == SLANG_SPEC_ARRAY) {
GLint i, pos;
assert(array_len > 0);
if (strcmp(name, "gl_ClipPlane") == 0) {
tokens[0] = STATE_CLIPPLANE;
}
else if (strcmp(name, "gl_LightSource") == 0) {
tokens[0] = STATE_LIGHT;
}
else if (strcmp(name, "gl_FrontLightProduct") == 0) {
tokens[0] = STATE_LIGHTPROD;
tokens[2] = 0; /* front */
}
else if (strcmp(name, "gl_BackLightProduct") == 0) {
tokens[0] = STATE_LIGHTPROD;
tokens[2] = 1; /* back */
}
else if (strcmp(name, "gl_TextureEnvColor") == 0) {
tokens[0] = STATE_TEXENV_COLOR;
}
else if (strcmp(name, "gl_EyePlaneS") == 0) {
tokens[0] = STATE_TEXGEN_EYE_S;
}
else if (strcmp(name, "gl_EyePlaneT") == 0) {
tokens[0] = STATE_TEXGEN_EYE_T;
}
else if (strcmp(name, "gl_EyePlaneR") == 0) {
tokens[0] = STATE_TEXGEN_EYE_R;
}
else if (strcmp(name, "gl_EyePlaneQ") == 0) {
tokens[0] = STATE_TEXGEN_EYE_Q;
}
else if (strcmp(name, "gl_ObjectPlaneS") == 0) {
tokens[0] = STATE_TEXGEN_OBJECT_S;
}
else if (strcmp(name, "gl_ObjectPlaneT") == 0) {
tokens[0] = STATE_TEXGEN_OBJECT_T;
}
else if (strcmp(name, "gl_ObjectPlaneR") == 0) {
tokens[0] = STATE_TEXGEN_OBJECT_R;
}
else if (strcmp(name, "gl_ObjectPlaneQ") == 0) {
tokens[0] = STATE_TEXGEN_OBJECT_Q;
}
else {
return -1; /* invalid array name */
}
for (i = 0; i < array_len; i++) {
GLint p;
tokens[1] = i;
p = emit_statevars(NULL, 0, type->_array, tokens, paramList);
if (i == 0)
pos = p;
}
return pos;
}
else if (type->type == SLANG_SPEC_STRUCT) {
const slang_variable_scope *fields = type->_struct->fields;
GLuint i, pos;
for (i = 0; i < fields->num_variables; i++) {
const slang_variable *var = fields->variables[i];
GLint p = emit_statevars(var->a_name, 0, &var->type.specifier,
tokens, paramList);
if (i == 0)
pos = p;
}
return pos;
}
else {
GLint pos;
assert(type->type == SLANG_SPEC_VEC4 ||
type->type == SLANG_SPEC_VEC3 ||
type->type == SLANG_SPEC_VEC2 ||
type->type == SLANG_SPEC_FLOAT ||
type->type == SLANG_SPEC_IVEC4 ||
type->type == SLANG_SPEC_IVEC3 ||
type->type == SLANG_SPEC_IVEC2 ||
type->type == SLANG_SPEC_INT);
if (name) {
GLint t;
if (tokens[0] == STATE_LIGHT)
t = 2;
else if (tokens[0] == STATE_LIGHTPROD)
t = 3;
else
return -1; /* invalid array name */
if (strcmp(name, "ambient") == 0) {
tokens[t] = STATE_AMBIENT;
}
else if (strcmp(name, "diffuse") == 0) {
tokens[t] = STATE_DIFFUSE;
}
else if (strcmp(name, "specular") == 0) {
tokens[t] = STATE_SPECULAR;
}
else if (strcmp(name, "position") == 0) {
tokens[t] = STATE_POSITION;
}
else if (strcmp(name, "halfVector") == 0) {
tokens[t] = STATE_HALF_VECTOR;
}
else if (strcmp(name, "spotDirection") == 0) {
tokens[t] = STATE_SPOT_DIRECTION; /* xyz components */
}
else if (strcmp(name, "spotCosCutoff") == 0) {
tokens[t] = STATE_SPOT_DIRECTION; /* w component */
}
else if (strcmp(name, "constantAttenuation") == 0) {
tokens[t] = STATE_ATTENUATION; /* x component */
}
else if (strcmp(name, "linearAttenuation") == 0) {
tokens[t] = STATE_ATTENUATION; /* y component */
}
else if (strcmp(name, "quadraticAttenuation") == 0) {
tokens[t] = STATE_ATTENUATION; /* z component */
}
else if (strcmp(name, "spotExponent") == 0) {
tokens[t] = STATE_ATTENUATION; /* w = spot exponent */
}
else if (strcmp(name, "spotCutoff") == 0) {
tokens[t] = STATE_SPOT_CUTOFF; /* x component */
}
else {
return -1; /* invalid field name */
}
}
pos = _mesa_add_state_reference(paramList, tokens);
return pos;
}
return 1;
}
/**
* Unroll the named built-in uniform variable into a sequence of state
* vars in the given parameter list.
*/
static GLint
alloc_state_var_array(const slang_variable *var,
struct gl_program_parameter_list *paramList)
{
gl_state_index tokens[STATE_LENGTH];
GLuint i;
GLint pos;
/* Initialize the state tokens array. This is very important.
* When we call _mesa_add_state_reference() it'll searches the parameter
* list to see if the given statevar token sequence is already present.
* This is normally a good thing since it prevents redundant values in the
* constant buffer.
*
* But when we're building arrays of state this can be bad. For example,
* consider this fragment of GLSL code:
* foo = gl_LightSource[3].diffuse;
* ...
* bar = gl_LightSource[i].diffuse;
*
* When we unroll the gl_LightSource array (for "bar") we want to re-emit
* gl_LightSource[3].diffuse and not re-use the first instance (from "foo")
* since that would upset the array layout. We handle this situation by
* setting the last token in the state var token array to the special
* value STATE_ARRAY.
* This token will only be set for array state. We can hijack the last
* element in the array for this since it's never used for light, clipplane
* or texture env array state.
*/
for (i = 0; i < STATE_LENGTH; i++)
tokens[i] = 0;
tokens[STATE_LENGTH - 1] = STATE_ARRAY;
pos = emit_statevars(var->a_name, var->array_len, &var->type.specifier,
tokens, paramList);
return pos;
}
/**
* Allocate storage for a pre-defined uniform (a GL state variable).
* As a memory-saving optimization, we try to only allocate storage for
* state vars that are actually used.
* For example, the "gl_LightSource" uniform is huge. If we only use
* a handful of gl_LightSource fields, we don't want to allocate storage
* for all of gl_LightSource.
*
* Arrays such as gl_LightSource are handled specially. For an expression
* like "gl_LightSource[2].diffuse", we can allocate a single uniform/constant
* slot and return the index. In this case, we return direct=TRUE.
*
* Buf for something like "gl_LightSource[i].diffuse" we don't know the value
* of 'i' at compile time so we need to "unroll" the gl_LightSource array
* into a consecutive sequence of uniform/constant slots so it can be indexed
* at runtime. In this case, we return direct=FALSE.
*
* Currently, all pre-defined uniforms are in one of these forms:
* var
@ -401,52 +642,62 @@ lookup_statevar(const char *var, GLint index1, GLint index2, const char *field,
* var[i].field
* var[i][j]
*
* \return -1 upon error, else position in paramList of the state var/data
* \return -1 upon error, else position in paramList of the state variable/data
*/
GLint
_slang_alloc_statevar(slang_ir_node *n,
struct gl_program_parameter_list *paramList)
struct gl_program_parameter_list *paramList,
GLboolean *direct)
{
slang_ir_node *n0 = n;
const char *field = NULL, *var;
GLint index1 = -1, index2 = -1, pos;
const char *field = NULL;
GLint index1 = -1, index2 = -1;
GLuint swizzle;
*direct = GL_TRUE;
if (n->Opcode == IR_FIELD) {
field = n->Field;
n = n->Children[0];
}
if (n->Opcode == IR_ELEMENT) {
/* XXX can only handle constant indexes for now */
if (n->Children[1]->Opcode == IR_FLOAT) {
index1 = (GLint) n->Children[1]->Value[0];
n = n->Children[0];
}
else {
return -1;
*direct = GL_FALSE;
}
n = n->Children[0];
}
if (n->Opcode == IR_ELEMENT) {
/* XXX can only handle constant indexes for now */
assert(n->Children[1]->Opcode == IR_FLOAT);
index2 = (GLint) n->Children[1]->Value[0];
if (n->Children[1]->Opcode == IR_FLOAT) {
index2 = (GLint) n->Children[1]->Value[0];
}
else {
*direct = GL_FALSE;
}
n = n->Children[0];
}
assert(n->Opcode == IR_VAR);
var = (char *) n->Var->a_name;
pos = lookup_statevar(var, index1, index2, field, &swizzle, paramList);
assert(pos >= 0);
if (pos >= 0) {
/* newly resolved storage for the statevar/constant/uniform */
n0->Store->File = PROGRAM_STATE_VAR;
n0->Store->Index = pos;
n0->Store->Swizzle = swizzle;
n0->Store->Parent = NULL;
if (*direct) {
const char *var = (const char *) n->Var->a_name;
GLint pos =
lookup_statevar(var, index1, index2, field, &swizzle, paramList);
if (pos >= 0) {
/* newly resolved storage for the statevar/constant/uniform */
n0->Store->File = PROGRAM_STATE_VAR;
n0->Store->Index = pos;
n0->Store->Swizzle = swizzle;
n0->Store->Parent = NULL;
return pos;
}
}
return pos;
}
*direct = GL_FALSE;
return alloc_state_var_array(n->Var, paramList);
}

View file

@ -33,7 +33,8 @@
extern GLint
_slang_alloc_statevar(slang_ir_node *n,
struct gl_program_parameter_list *paramList);
struct gl_program_parameter_list *paramList,
GLboolean *direct);
#endif /* SLANG_BUILTIN_H */

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