Merge commit 'origin/master' into gallium-0.2

Conflicts:

	progs/glsl/Makefile
This commit is contained in:
Alan Hourihane
2008-12-08 14:29:50 +00:00
29 changed files with 1106 additions and 707 deletions

View File

@@ -20,9 +20,9 @@ DEFINES = -D_DARWIN_C_SOURCE -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L \
ARCH_FLAGS += $(RC_CFLAGS)
CFLAGS = -g -O2 -Wall -Wmissing-prototypes -std=c99 -ffast-math -fno-strict-aliasing \
CFLAGS = -ggdb3 -Os -Wall -Wmissing-prototypes -std=c99 -ffast-math -fno-strict-aliasing \
-I$(INSTALL_DIR)/include $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(ASM_FLAGS) $(DEFINES)
CXXFLAGS = -g -O2 -Wall -fno-strict-aliasing \
CXXFLAGS = -ggdb3 -Os -Wall -fno-strict-aliasing \
-I$(INSTALL_DIR)/include $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(ASM_FLAGS) $(DEFINES)
# Library names (actual file names)

View File

@@ -23,7 +23,7 @@ AC_CANONICAL_HOST
dnl Versions for external dependencies
LIBDRM_REQUIRED=2.3.1
DRI2PROTO_REQUIRED=1.99.1
DRI2PROTO_REQUIRED=1.99.3
dnl Check for progs
AC_PROG_CPP

View File

@@ -27,7 +27,7 @@ PROGS = \
toyball \
twoside \
trirast \
texdemo1
vert-tex
##### RULES #####
@@ -189,7 +189,19 @@ trirast.o: trirast.c extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) trirast.c
trirast: trirast.o shaderutil.o
<<<<<<< HEAD:progs/glsl/Makefile
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) trirast.o shaderutil.o $(LIBS) -o $@
=======
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) trirast.o shaderutil.o $(LIBS) -o $@
vert-tex.o: vert-tex.c extfuncs.h shaderutil.h
$(CC) -c -I$(INCDIR) $(CFLAGS) vert-tex.c
vert-tex: vert-tex.o shaderutil.o
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) vert-tex.o shaderutil.o $(LIBS) -o $@
>>>>>>> origin/master:progs/glsl/Makefile

279
progs/glsl/vert-tex.c Normal file
View File

@@ -0,0 +1,279 @@
/**
* Vertex shader texture sampling test.
* Brian Paul
* 2 Dec 2008
*/
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GL/gl.h>
#include <GL/glut.h>
#include <GL/glext.h>
#include "extfuncs.h"
#include "shaderutil.h"
static const char *VertShaderText =
"uniform sampler2D tex1; \n"
"void main() \n"
"{ \n"
" vec4 pos = gl_Vertex; \n"
" pos.z = texture2D(tex1, gl_MultiTexCoord0.xy).x - 0.5; \n"
" gl_Position = gl_ModelViewProjectionMatrix * pos; \n"
" gl_FrontColor = pos; \n"
"} \n";
static const char *FragShaderText =
"void main() \n"
"{ \n"
" gl_FragColor = gl_Color; \n"
"} \n";
static GLuint fragShader;
static GLuint vertShader;
static GLuint program;
static GLint win = 0;
static GLboolean Anim = GL_TRUE;
static GLboolean WireFrame = GL_TRUE;
static GLfloat xRot = -70.0f, yRot = 0.0f, zRot = 0.0f;
/* value[0] = tex unit */
static struct uniform_info Uniforms[] = {
{ "tex1", 1, GL_INT, { 0, 0, 0, 0 }, -1 },
END_OF_UNIFORMS
};
static void
Idle(void)
{
zRot = 90 + glutGet(GLUT_ELAPSED_TIME) * 0.05;
glutPostRedisplay();
}
static void
DrawMesh(void)
{
GLfloat xmin = -2.0, xmax = 2.0;
GLfloat ymin = -2.0, ymax = 2.0;
GLuint xdivs = 20, ydivs = 20;
GLfloat dx = (xmax - xmin) / xdivs;
GLfloat dy = (ymax - ymin) / ydivs;
GLfloat ds = 1.0 / xdivs, dt = 1.0 / ydivs;
GLfloat x, y, s, t;
GLuint i, j;
y = ymin;
t = 0.0;
for (i = 0; i < ydivs; i++) {
x = xmin;
s = 0.0;
glBegin(GL_QUAD_STRIP);
for (j = 0; j < xdivs; j++) {
glTexCoord2f(s, t);
glVertex2f(x, y);
glTexCoord2f(s, t + dt);
glVertex2f(x, y + dy);
x += dx;
s += ds;
}
glEnd();
y += dy;
t += dt;
}
}
static void
Redisplay(void)
{
if (WireFrame)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
else
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
glRotatef(yRot, 0.0f, 1.0f, 0.0f);
glRotatef(zRot, 0.0f, 0.0f, 1.0f);
glPushMatrix();
DrawMesh();
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
}
static void
Reshape(int width, int height)
{
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -15.0f);
}
static void
CleanUp(void)
{
glDeleteShader_func(fragShader);
glDeleteShader_func(vertShader);
glDeleteProgram_func(program);
glutDestroyWindow(win);
}
static void
Key(unsigned char key, int x, int y)
{
const GLfloat step = 2.0;
(void) x;
(void) y;
switch(key) {
case 'a':
Anim = !Anim;
if (Anim)
glutIdleFunc(Idle);
else
glutIdleFunc(NULL);
break;
case 'w':
WireFrame = !WireFrame;
break;
case 'z':
zRot += step;
break;
case 'Z':
zRot -= step;
break;
case 27:
CleanUp();
exit(0);
break;
}
glutPostRedisplay();
}
static void
SpecialKey(int key, int x, int y)
{
const 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();
}
static void
MakeTexture(void)
{
const GLuint texWidth = 64, texHeight = 64;
GLfloat texImage[64][64];
GLuint i, j;
/* texture is basically z = f(x, y) */
for (i = 0; i < texHeight; i++) {
GLfloat y = 2.0 * (i / (float) (texHeight - 1)) - 1.0;
for (j = 0; j < texWidth; j++) {
GLfloat x = 2.0 * (j / (float) (texWidth - 1)) - 1.0;
GLfloat z = 0.5 + 0.5 * (sin(4.0 * x) * sin(4.0 * y));
texImage[i][j] = z;
}
}
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 42);
glTexImage2D(GL_TEXTURE_2D, 0, GL_INTENSITY, texWidth, texHeight, 0,
GL_LUMINANCE, GL_FLOAT, texImage);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
static void
Init(void)
{
GLint m;
glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, &m);
if (m < 1) {
printf("Error: no vertex shader texture units supported.\n");
exit(1);
}
if (!ShadersSupported())
exit(1);
GetExtensionFuncs();
vertShader = CompileShaderText(GL_VERTEX_SHADER, VertShaderText);
fragShader = CompileShaderText(GL_FRAGMENT_SHADER, FragShaderText);
program = LinkShaders(vertShader, fragShader);
glUseProgram_func(program);
assert(glGetError() == 0);
MakeTexture();
glClearColor(0.4f, 0.4f, 0.8f, 0.0f);
glEnable(GL_DEPTH_TEST);
glColor3f(1, 1, 1);
}
int
main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowSize(500, 500);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
win = glutCreateWindow(argv[0]);
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
glutSpecialFunc(SpecialKey);
glutDisplayFunc(Redisplay);
Init();
if (Anim)
glutIdleFunc(Idle);
glutMainLoop();
return 0;
}

View File

@@ -293,7 +293,6 @@ void DRI2CopyRegion(Display *dpy, XID drawable, XserverRegion region,
req->region = region;
req->dest = dest;
req->src = src;
req->bitmask = 0;
_XReply(dpy, (xReply *)&rep, 0, xFalse);

View File

@@ -117,6 +117,26 @@ intelDmaPrimitive(struct intel_context *intel, GLenum prim)
intel_set_prim(intel, hw_prim[prim]);
}
static inline GLuint intel_get_vb_max(struct intel_context *intel)
{
GLuint ret;
if (intel->intelScreen->no_vbo)
ret = intel->batch->size - 1500;
else
ret = INTEL_VB_SIZE;
ret /= (intel->vertex_size * 4);
return ret;
}
static inline GLuint intel_get_current_max(struct intel_context *intel)
{
if (intel->intelScreen->no_vbo)
return intel_get_vb_max(intel);
else
return (INTEL_VB_SIZE - intel->prim.current_offset) / (intel->vertex_size * 4);
}
#define LOCAL_VARS struct intel_context *intel = intel_context(ctx)
#define INIT( prim ) \
@@ -126,9 +146,8 @@ do { \
#define FLUSH() INTEL_FIREVERTICES(intel)
#define GET_SUBSEQUENT_VB_MAX_VERTS() (INTEL_VB_SIZE / (intel->vertex_size * 4))
#define GET_CURRENT_VB_MAX_VERTS() \
((INTEL_VB_SIZE - intel->prim.current_offset) / (intel->vertex_size * 4))
#define GET_SUBSEQUENT_VB_MAX_VERTS() intel_get_vb_max(intel)
#define GET_CURRENT_VB_MAX_VERTS() intel_get_current_max(intel)
#define ALLOC_VERTS(nr) intel_get_prim_space(intel, nr)

View File

@@ -61,9 +61,101 @@ static void intelRenderPrimitive(GLcontext * ctx, GLenum prim);
static void intelRasterPrimitive(GLcontext * ctx, GLenum rprim,
GLuint hwprim);
static void
intel_flush_inline_primitive(struct intel_context *intel)
{
GLuint used = intel->batch->ptr - intel->prim.start_ptr;
assert(intel->prim.primitive != ~0);
/* _mesa_printf("/\n"); */
if (used < 8)
goto do_discard;
*(int *) intel->prim.start_ptr = (_3DPRIMITIVE |
intel->prim.primitive | (used / 4 - 2));
goto finished;
do_discard:
intel->batch->ptr -= used;
finished:
intel->prim.primitive = ~0;
intel->prim.start_ptr = 0;
intel->prim.flush = 0;
}
static void intel_start_inline(struct intel_context *intel, uint32_t prim)
{
BATCH_LOCALS;
uint32_t batch_flags = LOOP_CLIPRECTS;
intel_wait_flips(intel);
intel->vtbl.emit_state(intel);
intel->no_batch_wrap = GL_TRUE;
/*_mesa_printf("%s *", __progname);*/
/* Emit a slot which will be filled with the inline primitive
* command later.
*/
BEGIN_BATCH(2, batch_flags);
OUT_BATCH(0);
assert((intel->batch->dirty_state & (1<<1)) == 0);
intel->prim.start_ptr = intel->batch->ptr;
intel->prim.primitive = prim;
intel->prim.flush = intel_flush_inline_primitive;
OUT_BATCH(0);
ADVANCE_BATCH();
intel->no_batch_wrap = GL_FALSE;
/* _mesa_printf(">"); */
}
static void intel_wrap_inline(struct intel_context *intel)
{
GLuint prim = intel->prim.primitive;
intel_flush_inline_primitive(intel);
intel_batchbuffer_flush(intel->batch);
intel_start_inline(intel, prim); /* ??? */
}
static GLuint *intel_extend_inline(struct intel_context *intel, GLuint dwords)
{
GLuint sz = dwords * sizeof(GLuint);
GLuint *ptr;
assert(intel->prim.flush == intel_flush_inline_primitive);
if (intel_batchbuffer_space(intel->batch) < sz)
intel_wrap_inline(intel);
/* _mesa_printf("."); */
intel->vtbl.assert_not_dirty(intel);
ptr = (GLuint *) intel->batch->ptr;
intel->batch->ptr += sz;
return ptr;
}
/** Sets the primitive type for a primitive sequence, flushing as needed. */
void intel_set_prim(struct intel_context *intel, uint32_t prim)
{
/* if we have no VBOs */
if (intel->intelScreen->no_vbo) {
intel_start_inline(intel, prim);
return;
}
if (prim != intel->prim.primitive) {
INTEL_FIREVERTICES(intel);
intel->prim.primitive = prim;
@@ -75,6 +167,10 @@ uint32_t *intel_get_prim_space(struct intel_context *intel, unsigned int count)
{
uint32_t *addr;
if (intel->intelScreen->no_vbo) {
return intel_extend_inline(intel, count * intel->vertex_size);
}
/* Check for space in the existing VB */
if (intel->prim.vb_bo == NULL ||
(intel->prim.current_offset +
@@ -155,7 +251,7 @@ void intel_flush_prim(struct intel_context *intel)
#if 0
printf("emitting %d..%d=%d vertices size %d\n", offset,
intel->prim.current_offset, intel->prim.count,
intel->prim.current_offset, count,
intel->vertex_size * 4);
#endif

View File

@@ -133,16 +133,16 @@ struct brw_context;
#define BRW_NEW_PSP 0x800
#define BRW_NEW_METAOPS 0x1000
#define BRW_NEW_FENCE 0x2000
#define BRW_NEW_LOCK 0x4000
#define BRW_NEW_INDICES 0x8000
#define BRW_NEW_VERTICES 0x10000
#define BRW_NEW_INDICES 0x4000
#define BRW_NEW_VERTICES 0x8000
/**
* Used for any batch entry with a relocated pointer that will be used
* by any 3D rendering.
*/
#define BRW_NEW_BATCH 0x8000
#define BRW_NEW_BATCH 0x10000
/** brw->depth_region updated */
#define BRW_NEW_DEPTH_BUFFER 0x10000
#define BRW_NEW_DEPTH_BUFFER 0x20000
#define BRW_NEW_NR_SURFACES 0x40000
struct brw_state_flags {
/** State update flags signalled by mesa internals */
@@ -158,7 +158,6 @@ struct brw_state_flags {
struct brw_vertex_program {
struct gl_vertex_program program;
GLuint id;
GLuint param_state; /* flags indicating state tracked by params */
};
@@ -166,7 +165,6 @@ struct brw_vertex_program {
struct brw_fragment_program {
struct gl_fragment_program program;
GLuint id;
GLuint param_state; /* flags indicating state tracked by params */
};

View File

@@ -184,8 +184,8 @@ static void prepare_constant_buffer(struct brw_context *brw)
* function will also be called whenever fp or vp changes.
*/
brw->curbe.tracked_state.dirty.mesa = (_NEW_TRANSFORM|_NEW_PROJECTION);
brw->curbe.tracked_state.dirty.mesa |= vp->param_state;
brw->curbe.tracked_state.dirty.mesa |= fp->param_state;
brw->curbe.tracked_state.dirty.mesa |= vp->program.Base.Parameters->StateFlags;
brw->curbe.tracked_state.dirty.mesa |= fp->program.Base.Parameters->StateFlags;
if (sz == 0) {

View File

@@ -49,7 +49,7 @@
#define FILE_DEBUG_FLAG DEBUG_BATCH
static GLuint hw_prim[GL_POLYGON+1] = {
static GLuint prim_to_hw_prim[GL_POLYGON+1] = {
_3DPRIM_POINTLIST,
_3DPRIM_LINELIST,
_3DPRIM_LINELOOP,
@@ -103,12 +103,9 @@ static GLuint brw_set_prim(struct brw_context *brw, GLenum prim)
brw->intel.reduced_primitive = reduced_prim[prim];
brw->state.dirty.brw |= BRW_NEW_REDUCED_PRIMITIVE;
}
brw_validate_state(brw);
brw_upload_state(brw);
}
return hw_prim[prim];
return prim_to_hw_prim[prim];
}
@@ -124,8 +121,8 @@ static GLuint trim(GLenum prim, GLuint length)
static void brw_emit_prim(struct brw_context *brw,
const struct _mesa_prim *prim )
const struct _mesa_prim *prim,
uint32_t hw_prim)
{
struct brw_3d_primitive prim_packet;
@@ -136,7 +133,7 @@ static void brw_emit_prim( struct brw_context *brw,
prim_packet.header.opcode = CMD_3D_PRIM;
prim_packet.header.length = sizeof(prim_packet)/4 - 2;
prim_packet.header.pad = 0;
prim_packet.header.topology = brw_set_prim(brw, prim->mode);
prim_packet.header.topology = hw_prim;
prim_packet.header.indexed = prim->indexed;
prim_packet.verts_per_instance = trim(prim->mode, prim->count);
@@ -258,11 +255,15 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx,
struct brw_context *brw = brw_context(ctx);
GLboolean retval = GL_FALSE;
GLboolean warn = GL_FALSE;
GLboolean first_time = GL_TRUE;
GLuint i;
if (ctx->NewState)
_mesa_update_state( ctx );
if (check_fallbacks(brw, prim, nr_prims))
return GL_FALSE;
brw_validate_textures( brw );
/* Bind all inputs, derive varying and size information:
@@ -275,6 +276,7 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx,
brw->vb.min_index = min_index;
brw->vb.max_index = max_index;
brw->state.dirty.brw |= BRW_NEW_VERTICES;
/* Have to validate state quite late. Will rebuild tnl_program,
* which depends on varying information.
*
@@ -289,6 +291,9 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx,
return GL_TRUE;
}
for (i = 0; i < nr_prims; i++) {
uint32_t hw_prim;
/* Flush the batch if it's approaching full, so that we don't wrap while
* we've got validated state that needs to be in the same batch as the
* primitives. This fraction is just a guess (minimal full state plus
@@ -298,20 +303,17 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx,
*/
intel_batchbuffer_require_space(intel->batch, intel->batch->size / 4,
LOOP_CLIPRECTS);
{
/* Set the first primitive early, ahead of validate_state:
*/
brw_set_prim(brw, prim[0].mode);
brw_validate_state( brw );
hw_prim = brw_set_prim(brw, prim[i].mode);
/* Various fallback checks:
*/
if (first_time || (brw->state.dirty.brw & BRW_NEW_PRIMITIVE)) {
first_time = GL_FALSE;
/* Various fallback checks: */
if (brw->intel.Fallback)
goto out;
if (check_fallbacks( brw, prim, nr_prims ))
goto out;
brw_validate_state(brw);
/* Check that we can fit our state in with our existing batchbuffer, or
* flush otherwise.
@@ -337,11 +339,10 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx,
}
brw_upload_state(brw);
for (i = 0; i < nr_prims; i++) {
brw_emit_prim(brw, &prim[i]);
}
brw_emit_prim(brw, &prim[i], hw_prim);
retval = GL_TRUE;
}

View File

@@ -117,7 +117,6 @@ static void brwProgramStringNotify( GLcontext *ctx,
if (p == fp)
brw->state.dirty.brw |= BRW_NEW_FRAGMENT_PROGRAM;
p->id = brw->program_id++;
p->param_state = p->program.Base.Parameters->StateFlags;
}
else if (target == GL_VERTEX_PROGRAM_ARB) {
struct brw_context *brw = brw_context(ctx);
@@ -129,7 +128,6 @@ static void brwProgramStringNotify( GLcontext *ctx,
_mesa_insert_mvp_code(ctx, &p->program);
}
p->id = brw->program_id++;
p->param_state = p->program.Base.Parameters->StateFlags;
/* Also tell tnl about it:
*/

View File

@@ -181,6 +181,118 @@ brw_clear_validated_bos(struct brw_context *brw)
brw->state.validated_bo_count = 0;
}
struct dirty_bit_map {
uint32_t bit;
char *name;
uint32_t count;
};
#define DEFINE_BIT(name) {name, #name, 0}
static struct dirty_bit_map mesa_bits[] = {
DEFINE_BIT(_NEW_MODELVIEW),
DEFINE_BIT(_NEW_PROJECTION),
DEFINE_BIT(_NEW_TEXTURE_MATRIX),
DEFINE_BIT(_NEW_COLOR_MATRIX),
DEFINE_BIT(_NEW_ACCUM),
DEFINE_BIT(_NEW_COLOR),
DEFINE_BIT(_NEW_DEPTH),
DEFINE_BIT(_NEW_EVAL),
DEFINE_BIT(_NEW_FOG),
DEFINE_BIT(_NEW_HINT),
DEFINE_BIT(_NEW_LIGHT),
DEFINE_BIT(_NEW_LINE),
DEFINE_BIT(_NEW_PIXEL),
DEFINE_BIT(_NEW_POINT),
DEFINE_BIT(_NEW_POLYGON),
DEFINE_BIT(_NEW_POLYGONSTIPPLE),
DEFINE_BIT(_NEW_SCISSOR),
DEFINE_BIT(_NEW_STENCIL),
DEFINE_BIT(_NEW_TEXTURE),
DEFINE_BIT(_NEW_TRANSFORM),
DEFINE_BIT(_NEW_VIEWPORT),
DEFINE_BIT(_NEW_PACKUNPACK),
DEFINE_BIT(_NEW_ARRAY),
DEFINE_BIT(_NEW_RENDERMODE),
DEFINE_BIT(_NEW_BUFFERS),
DEFINE_BIT(_NEW_MULTISAMPLE),
DEFINE_BIT(_NEW_TRACK_MATRIX),
DEFINE_BIT(_NEW_PROGRAM),
{0, 0, 0}
};
static struct dirty_bit_map brw_bits[] = {
DEFINE_BIT(BRW_NEW_URB_FENCE),
DEFINE_BIT(BRW_NEW_FRAGMENT_PROGRAM),
DEFINE_BIT(BRW_NEW_VERTEX_PROGRAM),
DEFINE_BIT(BRW_NEW_INPUT_DIMENSIONS),
DEFINE_BIT(BRW_NEW_CURBE_OFFSETS),
DEFINE_BIT(BRW_NEW_REDUCED_PRIMITIVE),
DEFINE_BIT(BRW_NEW_PRIMITIVE),
DEFINE_BIT(BRW_NEW_CONTEXT),
DEFINE_BIT(BRW_NEW_WM_INPUT_DIMENSIONS),
DEFINE_BIT(BRW_NEW_INPUT_VARYING),
DEFINE_BIT(BRW_NEW_PSP),
DEFINE_BIT(BRW_NEW_METAOPS),
DEFINE_BIT(BRW_NEW_FENCE),
DEFINE_BIT(BRW_NEW_INDICES),
DEFINE_BIT(BRW_NEW_VERTICES),
DEFINE_BIT(BRW_NEW_BATCH),
DEFINE_BIT(BRW_NEW_DEPTH_BUFFER),
{0, 0, 0}
};
static struct dirty_bit_map cache_bits[] = {
DEFINE_BIT(CACHE_NEW_CC_VP),
DEFINE_BIT(CACHE_NEW_CC_UNIT),
DEFINE_BIT(CACHE_NEW_WM_PROG),
DEFINE_BIT(CACHE_NEW_SAMPLER_DEFAULT_COLOR),
DEFINE_BIT(CACHE_NEW_SAMPLER),
DEFINE_BIT(CACHE_NEW_WM_UNIT),
DEFINE_BIT(CACHE_NEW_SF_PROG),
DEFINE_BIT(CACHE_NEW_SF_VP),
DEFINE_BIT(CACHE_NEW_SF_UNIT),
DEFINE_BIT(CACHE_NEW_VS_UNIT),
DEFINE_BIT(CACHE_NEW_VS_PROG),
DEFINE_BIT(CACHE_NEW_GS_UNIT),
DEFINE_BIT(CACHE_NEW_GS_PROG),
DEFINE_BIT(CACHE_NEW_CLIP_VP),
DEFINE_BIT(CACHE_NEW_CLIP_UNIT),
DEFINE_BIT(CACHE_NEW_CLIP_PROG),
DEFINE_BIT(CACHE_NEW_SURFACE),
DEFINE_BIT(CACHE_NEW_SURF_BIND),
{0, 0, 0}
};
static void
brw_update_dirty_count(struct dirty_bit_map *bit_map, int32_t bits)
{
int i;
for (i = 0; i < 32; i++) {
if (bit_map[i].bit == 0)
return;
if (bit_map[i].bit & bits)
bit_map[i].count++;
}
}
static void
brw_print_dirty_count(struct dirty_bit_map *bit_map, int32_t bits)
{
int i;
for (i = 0; i < 32; i++) {
if (bit_map[i].bit == 0)
return;
fprintf(stderr, "0x%08x: %12d (%s)\n",
bit_map[i].bit, bit_map[i].count, bit_map[i].name);
}
}
/***********************************************************************
* Emit all state:
*/
@@ -246,6 +358,7 @@ void brw_upload_state(struct brw_context *brw)
{
struct brw_state_flags *state = &brw->state.dirty;
int i;
static int dirty_count = 0;
brw_clear_validated_bos(brw);
@@ -301,6 +414,18 @@ void brw_upload_state(struct brw_context *brw)
}
}
if (INTEL_DEBUG & DEBUG_STATE) {
brw_update_dirty_count(mesa_bits, state->mesa);
brw_update_dirty_count(brw_bits, state->brw);
brw_update_dirty_count(cache_bits, state->cache);
if (dirty_count++ % 1000 == 0) {
brw_print_dirty_count(mesa_bits, state->mesa);
brw_print_dirty_count(brw_bits, state->brw);
brw_print_dirty_count(cache_bits, state->cache);
fprintf(stderr, "\n");
}
}
if (!brw->intel.Fallback)
memset(state, 0, sizeof(*state));
}

View File

@@ -171,8 +171,6 @@ static void brw_note_unlock( struct intel_context *intel )
struct brw_context *brw = brw_context(&intel->ctx);
brw_state_cache_check_size(brw);
brw_context(&intel->ctx)->state.dirty.brw |= BRW_NEW_LOCK;
}

View File

@@ -230,12 +230,6 @@ static void brw_wm_populate_key( struct brw_context *brw,
lookup |= IZ_STENCIL_WRITE_ENABLE_BIT;
}
/* XXX: when should this be disabled?
*/
if (1)
lookup |= IZ_EARLY_DEPTH_TEST_BIT;
line_aa = AA_NEVER;
/* _NEW_LINE, _NEW_POLYGON, BRW_NEW_REDUCED_PRIMITIVE */

View File

@@ -49,8 +49,7 @@
#define IZ_DEPTH_TEST_ENABLE_BIT 0x8
#define IZ_STENCIL_WRITE_ENABLE_BIT 0x10
#define IZ_STENCIL_TEST_ENABLE_BIT 0x20
#define IZ_EARLY_DEPTH_TEST_BIT 0x40
#define IZ_BIT_MAX 0x80
#define IZ_BIT_MAX 0x40
#define AA_NEVER 0
#define AA_SOMETIMES 1

View File

@@ -426,10 +426,6 @@ static struct prog_src_register search_or_add_param5(struct brw_wm_compile *c,
idx = _mesa_add_state_reference( paramList, tokens );
/* Recalculate state dependency:
*/
c->fp->param_state = paramList->StateFlags;
return src_reg(PROGRAM_STATE_VAR, idx);
}

View File

@@ -50,70 +50,6 @@ const struct {
GLuint ds_present:1;
} wm_iz_table[IZ_BIT_MAX] =
{
{ P, 0, 0, 0, 0 },
{ P, 0, 0, 0, 0 },
{ C, 0, 1, 0, 0 },
{ C, 0, 1, 0, 0 },
{ C, 1, 1, 0, 0 },
{ C, 1, 1, 0, 0 },
{ C, 0, 1, 0, 0 },
{ C, 0, 1, 0, 0 },
{ C, 1, 1, 1, 0 },
{ C, 1, 1, 1, 0 },
{ C, 0, 1, 1, 0 },
{ C, 0, 1, 1, 0 },
{ C, 1, 1, 1, 0 },
{ C, 1, 1, 1, 0 },
{ C, 0, 1, 1, 0 },
{ C, 0, 1, 1, 0 },
{ P, 0, 0, 0, 0 },
{ P, 0, 0, 0, 0 },
{ C, 0, 1, 0, 0 },
{ C, 0, 1, 0, 0 },
{ C, 1, 1, 0, 0 },
{ C, 1, 1, 0, 0 },
{ C, 0, 1, 0, 0 },
{ C, 0, 1, 0, 0 },
{ C, 1, 1, 1, 0 },
{ C, 1, 1, 1, 0 },
{ C, 0, 1, 1, 0 },
{ C, 0, 1, 1, 0 },
{ C, 1, 1, 1, 0 },
{ C, 1, 1, 1, 0 },
{ C, 0, 1, 1, 0 },
{ C, 0, 1, 1, 0 },
{ C, 0, 0, 0, 1 },
{ C, 0, 0, 0, 1 },
{ C, 0, 1, 0, 1 },
{ C, 0, 1, 0, 1 },
{ C, 1, 1, 0, 1 },
{ C, 1, 1, 0, 1 },
{ C, 0, 1, 0, 1 },
{ C, 0, 1, 0, 1 },
{ C, 1, 1, 1, 1 },
{ C, 1, 1, 1, 1 },
{ C, 0, 1, 1, 1 },
{ C, 0, 1, 1, 1 },
{ C, 1, 1, 1, 1 },
{ C, 1, 1, 1, 1 },
{ C, 0, 1, 1, 1 },
{ C, 0, 1, 1, 1 },
{ C, 0, 0, 0, 1 },
{ C, 0, 0, 0, 1 },
{ C, 0, 1, 0, 1 },
{ C, 0, 1, 0, 1 },
{ C, 1, 1, 0, 1 },
{ C, 1, 1, 0, 1 },
{ C, 0, 1, 0, 1 },
{ C, 0, 1, 0, 1 },
{ C, 1, 1, 1, 1 },
{ C, 1, 1, 1, 1 },
{ C, 0, 1, 1, 1 },
{ C, 0, 1, 1, 1 },
{ C, 1, 1, 1, 1 },
{ C, 1, 1, 1, 1 },
{ C, 0, 1, 1, 1 },
{ C, 0, 1, 1, 1 },
{ P, 0, 0, 0, 0 },
{ P, 0, 0, 0, 0 },
{ P, 0, 0, 0, 0 },

View File

@@ -88,7 +88,7 @@ wm_unit_populate_key(struct brw_context *brw, struct brw_wm_unit_key *key)
/* BRW_NEW_CURBE_OFFSETS */
key->curbe_offset = brw->curbe.wm_start;
/* CACHE_NEW_SURFACE */
/* BRW_NEW_NR_SURFACEs */
key->nr_surfaces = brw->wm.nr_surfaces;
/* CACHE_NEW_SAMPLER */
@@ -281,10 +281,9 @@ const struct brw_tracked_state brw_wm_unit = {
.brw = (BRW_NEW_FRAGMENT_PROGRAM |
BRW_NEW_CURBE_OFFSETS |
BRW_NEW_LOCK),
BRW_NEW_NR_SURFACES),
.cache = (CACHE_NEW_SURFACE |
CACHE_NEW_WM_PROG |
.cache = (CACHE_NEW_WM_PROG |
CACHE_NEW_SAMPLER)
},
.prepare = upload_wm_unit,

View File

@@ -438,6 +438,7 @@ static void prepare_wm_surfaces(struct brw_context *brw )
GLcontext *ctx = &brw->intel.ctx;
struct intel_context *intel = &brw->intel;
GLuint i;
int old_nr_surfaces;
if (brw->state.nr_draw_regions > 1) {
for (i = 0; i < brw->state.nr_draw_regions; i++) {
@@ -448,6 +449,7 @@ static void prepare_wm_surfaces(struct brw_context *brw )
brw_update_region_surface(brw, brw->state.draw_regions[0], 0, GL_TRUE);
}
old_nr_surfaces = brw->wm.nr_surfaces;
brw->wm.nr_surfaces = MAX_DRAW_BUFFERS;
for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {
@@ -473,6 +475,9 @@ static void prepare_wm_surfaces(struct brw_context *brw )
dri_bo_unreference(brw->wm.bind_bo);
brw->wm.bind_bo = brw_wm_get_binding_table(brw);
if (brw->wm.nr_surfaces != old_nr_surfaces)
brw->state.dirty.brw |= BRW_NEW_NR_SURFACES;
}

View File

@@ -184,6 +184,7 @@ struct intel_context
GLuint id;
uint32_t primitive; /**< Current hardware primitive type */
void (*flush) (struct intel_context *);
GLubyte *start_ptr; /**< for i8xx */
dri_bo *vb_bo;
uint8_t *vb;
unsigned int start_offset; /**< Byte offset of primitive sequence */

View File

@@ -71,14 +71,14 @@
/** @{
* 915 definitions
*/
#define S0_VB_OFFSET_MASK 0xffffffc
#define S0_VB_OFFSET_MASK 0xffffffc0
#define S0_AUTO_CACHE_INV_DISABLE (1<<0)
/** @} */
/** @{
* 830 definitions
*/
#define S0_VB_OFFSET_MASK_830 0xffffff8
#define S0_VB_OFFSET_MASK_830 0xffffff80
#define S0_VB_PITCH_SHIFT_830 1
#define S0_VB_ENABLE_830 (1<<0)
/** @} */

View File

@@ -461,6 +461,7 @@ intelCreateContext(const __GLcontextModes * mesaVis,
sharedContextPrivate);
}
} else {
intelScreen->no_vbo = GL_TRUE;
return i830CreateContext(mesaVis, driContextPriv, sharedContextPrivate);
}
#else

View File

@@ -77,6 +77,7 @@ typedef struct
GLboolean no_hw;
GLboolean no_vbo;
int ttm;
dri_bufmgr *bufmgr;

View File

@@ -98,7 +98,9 @@ do_copy_texsubimage(struct intel_context *intel,
get_teximage_source(intel, internalFormat);
if (!intelImage->mt || !src) {
DBG("%s fail %p %p\n", __FUNCTION__, intelImage->mt, src);
if (INTEL_DEBUG & DEBUG_FALLBACKS)
fprintf(stderr, "%s fail %p %p\n",
__FUNCTION__, intelImage->mt, src);
return GL_FALSE;
}

View File

@@ -2004,7 +2004,7 @@ save_Lightfv(GLenum light, GLenum pname, const GLfloat *params)
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION(ctx, OPCODE_LIGHT, 6);
if (OPCODE_LIGHT) {
if (n) {
GLint i, nParams;
n[1].e = light;
n[2].e = pname;

View File

@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
* Version: 7.1
* Version: 7.3
*
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
@@ -297,6 +297,15 @@ _mesa_enable_sw_extensions(GLcontext *ctx)
#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE;
#endif
#if FEATURE_texture_fxt1
_mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1");
#endif
#if FEATURE_texture_s3tc
if (ctx->Mesa_DXTn) {
_mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
_mesa_enable_extension(ctx, "GL_S3_s3tc");
}
#endif
}

View File

@@ -151,8 +151,6 @@ _mesa_compressed_texture_size( GLcontext *ctx,
/* Textures smaller than 8x4 will effectively be made into 8x4 and
* take 16 bytes.
*/
if (size < 16)
size = 16;
return size;
#endif
#if FEATURE_texture_s3tc
@@ -166,8 +164,6 @@ _mesa_compressed_texture_size( GLcontext *ctx,
/* Textures smaller than 4x4 will effectively be made into 4x4 and
* take 8 bytes.
*/
if (size < 8)
size = 8;
return size;
case MESA_FORMAT_RGBA_DXT3:
case MESA_FORMAT_RGBA_DXT5:
@@ -179,8 +175,6 @@ _mesa_compressed_texture_size( GLcontext *ctx,
/* Textures smaller than 4x4 will effectively be made into 4x4 and
* take 16 bytes.
*/
if (size < 16)
size = 16;
return size;
#endif
default:

View File

@@ -632,7 +632,7 @@ append(char *dst, const char *src)
/**
* Convert token 'k' to a string, append it only 'dst' string.
* Convert token 'k' to a string, append it onto 'dst' string.
*/
static void
append_token(char *dst, gl_state_index k)
@@ -807,7 +807,8 @@ append_token(char *dst, gl_state_index k)
append(dst, "ShadowAmbient");
break;
default:
;
/* probably STATE_INTERNAL_DRIVER+i (driver private state) */
append(dst, "driverState");
}
}

File diff suppressed because it is too large Load Diff