summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/SConscript18
-rw-r--r--src/mesa/main/bufferobj.c4
-rw-r--r--src/mesa/main/bufferobj.h4
-rw-r--r--src/mesa/main/drawpix.c5
-rw-r--r--src/mesa/shader/prog_statevars.c8
-rw-r--r--src/mesa/state_tracker/st_atom_texture.c30
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.c9
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c4
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c191
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c8
-rw-r--r--src/mesa/state_tracker/st_cb_program.c12
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c47
-rw-r--r--src/mesa/state_tracker/st_context.c11
-rw-r--r--src/mesa/state_tracker/st_context.h4
-rw-r--r--src/mesa/state_tracker/st_draw.c134
-rw-r--r--src/mesa/state_tracker/st_draw.h7
-rw-r--r--src/mesa/state_tracker/st_extensions.c6
-rw-r--r--src/mesa/state_tracker/st_program.c2
-rw-r--r--src/mesa/state_tracker/st_texture.c5
-rw-r--r--src/mesa/swrast/s_drawpix.c2
20 files changed, 274 insertions, 237 deletions
diff --git a/src/mesa/SConscript b/src/mesa/SConscript
index 80fbdb41f05..6b99dacf2a6 100644
--- a/src/mesa/SConscript
+++ b/src/mesa/SConscript
@@ -12,9 +12,19 @@ env.Append(CPPPATH = [
'#/src/mesa/main',
])
-env.Append(CFLAGS = [
- '-std=c99',
-])
+if gcc:
+ env.Append(CFLAGS = [
+ '-std=c99',
+ ])
+
+# x86 assembly
+if x86 and gcc:
+ env.Append(CPPDEFINES = [
+ 'USE_X86_ASM',
+ 'USE_MMX_ASM',
+ 'USE_3DNOW_ASM',
+ 'USE_SSE_ASM',
+ ])
#######################################################################
@@ -269,7 +279,7 @@ SPARC_API = [
'sparc/glapi_sparc.S',
]
-if x86:
+if x86 and gcc:
ASM_SOURCES = ASM_C_SOURCES + X86_SOURCES
API_SOURCES = X86_API
else:
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index e762eb3b634..dc0307feb56 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -551,8 +551,8 @@ _mesa_map_drawpix_pbo(GLcontext *ctx,
* \sa _mesa_unmap_bitmap_pbo
*/
void
-_mesa_unmap_drapix_pbo(GLcontext *ctx,
- const struct gl_pixelstore_attrib *unpack)
+_mesa_unmap_drawpix_pbo(GLcontext *ctx,
+ const struct gl_pixelstore_attrib *unpack)
{
if (unpack->BufferObj->Name) {
ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index 46525f08ae3..024e5a8c3c8 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -101,8 +101,8 @@ _mesa_map_drawpix_pbo(GLcontext *ctx,
const GLvoid *pixels);
extern void
-_mesa_unmap_drapix_pbo(GLcontext *ctx,
- const struct gl_pixelstore_attrib *unpack);
+_mesa_unmap_drawpix_pbo(GLcontext *ctx,
+ const struct gl_pixelstore_attrib *unpack);
extern void *
diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c
index 0f64f1c1c0c..fa422bb3c76 100644
--- a/src/mesa/main/drawpix.c
+++ b/src/mesa/main/drawpix.c
@@ -377,8 +377,9 @@ _mesa_Bitmap( GLsizei width, GLsizei height,
if (ctx->RenderMode == GL_RENDER) {
/* Truncate, to satisfy conformance tests (matches SGI's OpenGL). */
- GLint x = IFLOOR(ctx->Current.RasterPos[0] - xorig);
- GLint y = IFLOOR(ctx->Current.RasterPos[1] - yorig);
+ const GLfloat epsilon = 0.0001;
+ GLint x = IFLOOR(ctx->Current.RasterPos[0] + epsilon - xorig);
+ GLint y = IFLOOR(ctx->Current.RasterPos[1] + epsilon - yorig);
if (ctx->Unpack.BufferObj->Name) {
/* unpack from PBO */
diff --git a/src/mesa/shader/prog_statevars.c b/src/mesa/shader/prog_statevars.c
index 45352d30b5c..eee4d2d9259 100644
--- a/src/mesa/shader/prog_statevars.c
+++ b/src/mesa/shader/prog_statevars.c
@@ -253,7 +253,8 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[],
value[0] = ctx->Fog.Density;
value[1] = ctx->Fog.Start;
value[2] = ctx->Fog.End;
- value[3] = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
+ value[3] = (ctx->Fog.End == ctx->Fog.Start)
+ ? 1.0 : 1.0F / (ctx->Fog.End - ctx->Fog.Start);
return;
case STATE_CLIPPLANE:
{
@@ -424,8 +425,9 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[],
* exp: 2^-(density/ln(2) * fogcoord)
* exp2: 2^-((density/(ln(2)^2) * fogcoord)^2)
*/
- value[0] = -1.0F / (ctx->Fog.End - ctx->Fog.Start);
- value[1] = ctx->Fog.End / (ctx->Fog.End - ctx->Fog.Start);
+ value[0] = (ctx->Fog.End == ctx->Fog.Start)
+ ? 1.0 : -1.0F / (ctx->Fog.End - ctx->Fog.Start);
+ value[1] = ctx->Fog.End * -value[0];
value[2] = ctx->Fog.Density * ONE_DIV_LN2;
value[3] = ctx->Fog.Density * ONE_DIV_SQRT_LN2;
return;
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index 01c07dc26d3..d15da5895ab 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -38,6 +38,23 @@
#include "st_cb_texture.h"
#include "pipe/p_context.h"
#include "pipe/p_inlines.h"
+#include "cso_cache/cso_context.h"
+#include "util/u_simple_shaders.h"
+
+
+static void *
+get_passthrough_fs(struct st_context *st)
+{
+ struct pipe_shader_state shader;
+
+ if (!st->passthrough_fs) {
+ st->passthrough_fs =
+ util_make_fragment_passthrough_shader(st->pipe, &shader);
+ free((void *) shader.tokens);
+ }
+
+ return st->passthrough_fs;
+}
/**
@@ -49,6 +66,7 @@ update_textures(struct st_context *st)
{
struct gl_fragment_program *fprog = st->ctx->FragmentProgram._Current;
GLuint su;
+ GLboolean missing_textures = GL_FALSE;
st->state.num_textures = 0;
@@ -67,6 +85,7 @@ update_textures(struct st_context *st)
retval = st_finalize_texture(st->ctx, st->pipe, texObj, &flush);
if (!retval) {
/* out of mem */
+ missing_textures = GL_TRUE;
continue;
}
@@ -79,8 +98,15 @@ update_textures(struct st_context *st)
pipe_texture_reference(&st->state.sampler_texture[su], pt);
}
- st->pipe->set_sampler_textures(st->pipe, st->state.num_textures,
- st->state.sampler_texture);
+ cso_set_sampler_textures(st->cso_context,
+ st->state.num_textures,
+ st->state.sampler_texture);
+
+ if (missing_textures) {
+ /* use a pass-through frag shader that uses no textures */
+ void *fs = get_passthrough_fs(st);
+ cso_set_fragment_shader_handle(st->cso_context, fs);
+ }
}
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index 7752b40e8ba..6c2d9a4b897 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -355,11 +355,8 @@ setup_bitmap_vertex_data(struct st_context *st,
const GLfloat x1 = x + width;
const GLfloat y0 = y;
const GLfloat y1 = y + height;
- const GLfloat bias = st->bitmap_texcoord_bias;
- const GLfloat xBias = bias / (x1-x0);
- const GLfloat yBias = bias / (y1-y0);
- const GLfloat sLeft = 0.0 + xBias, sRight = 1.0 + xBias;
- const GLfloat tTop = yBias, tBot = 1.0 - tTop - yBias;
+ const GLfloat sLeft = 0.0F, sRight = 1.0F;
+ const GLfloat tTop = 0.0, tBot = 1.0 - tTop;
const GLfloat clip_x0 = x0 / fb_width * 2.0 - 1.0;
const GLfloat clip_y0 = y0 / fb_height * 2.0 - 1.0;
const GLfloat clip_x1 = x1 / fb_width * 2.0 - 1.0;
@@ -803,7 +800,7 @@ st_destroy_bitmap(struct st_context *st)
}
#endif
if (st->bitmap.vs) {
- pipe->delete_vs_state(pipe, st->bitmap.vs);
+ cso_delete_vertex_shader(st->cso_context, st->bitmap.vs);
st->bitmap.vs = NULL;
}
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index dac346a06c1..95a5fb8db47 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -98,11 +98,11 @@ st_destroy_clear(struct st_context *st)
struct pipe_context *pipe = st->pipe;
if (st->clear.fs) {
- pipe->delete_fs_state(pipe, st->clear.fs);
+ cso_delete_fragment_shader(st->cso_context, st->clear.fs);
st->clear.fs = NULL;
}
if (st->clear.vs) {
- pipe->delete_vs_state(pipe, st->clear.vs);
+ cso_delete_vertex_shader(st->cso_context, st->clear.vs);
st->clear.vs = NULL;
}
if (st->clear.vbuf) {
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 3921500659d..047ea3816bc 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -349,7 +349,7 @@ make_texture(struct st_context *st,
pt = st_texture_create(st, PIPE_TEXTURE_2D, pipeFormat, 0, width, height,
1, 0);
if (!pt) {
- _mesa_unmap_drapix_pbo(ctx, unpack);
+ _mesa_unmap_drawpix_pbo(ctx, unpack);
return NULL;
}
@@ -395,111 +395,109 @@ make_texture(struct st_context *st,
ctx->_ImageTransferState = imageTransferStateSave;
}
- _mesa_unmap_drapix_pbo(ctx, unpack);
+ _mesa_unmap_drawpix_pbo(ctx, unpack);
return pt;
}
/**
- * Draw textured quad.
+ * Draw quad with texcoords and optional color.
* Coords are window coords with y=0=bottom.
+ * \param color may be null
+ * \param invertTex if true, flip texcoords vertically
*/
static void
draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z,
- GLfloat x1, GLfloat y1, GLboolean invertTex)
+ GLfloat x1, GLfloat y1, const GLfloat *color,
+ GLboolean invertTex)
{
- GLfloat verts[4][2][4]; /* four verts, two attribs, XYZW */
- GLuint i;
- GLfloat sLeft = 0.0, sRight = 1.0;
- GLfloat tTop = invertTex, tBot = 1.0 - tTop;
-
- /* upper-left */
- verts[0][0][0] = x0; /* attr[0].x */
- verts[0][0][1] = y0; /* attr[0].y */
- verts[0][1][0] = sLeft; /* attr[1].s */
- verts[0][1][1] = tTop; /* attr[1].t */
-
- /* upper-right */
- verts[1][0][0] = x1;
- verts[1][0][1] = y0;
- verts[1][1][0] = sRight;
- verts[1][1][1] = tTop;
-
- /* lower-right */
- verts[2][0][0] = x1;
- verts[2][0][1] = y1;
- verts[2][1][0] = sRight;
- verts[2][1][1] = tBot;
-
- /* lower-left */
- verts[3][0][0] = x0;
- verts[3][0][1] = y1;
- verts[3][1][0] = sLeft;
- verts[3][1][1] = tBot;
-
- /* same for all verts: */
- for (i = 0; i < 4; i++) {
- verts[i][0][2] = z; /*Z*/
- verts[i][0][3] = 1.0; /*W*/
- verts[i][1][2] = 0.0; /*R*/
- verts[i][1][3] = 1.0; /*Q*/
- }
-
- st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 2, GL_FALSE);
-}
-
-
-static void
-draw_quad_colored(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z,
- GLfloat x1, GLfloat y1, const GLfloat *color,
- GLboolean invertTex)
-{
- GLfloat bias = ctx->st->bitmap_texcoord_bias;
+ struct st_context *st = ctx->st;
+ struct pipe_context *pipe = ctx->st->pipe;
GLfloat verts[4][3][4]; /* four verts, three attribs, XYZW */
- GLuint i;
- GLfloat xBias = bias / (x1-x0);
- GLfloat yBias = bias / (y1-y0);
- GLfloat sLeft = 0.0 + xBias, sRight = 1.0 + xBias;
- GLfloat tTop = invertTex - yBias, tBot = 1.0 - tTop - yBias;
-
- /* upper-left */
- verts[0][0][0] = x0; /* attr[0].x */
- verts[0][0][1] = y0; /* attr[0].y */
- verts[0][2][0] = sLeft; /* attr[2].s */
- verts[0][2][1] = tTop; /* attr[2].t */
-
- /* upper-right */
- verts[1][0][0] = x1;
- verts[1][0][1] = y0;
- verts[1][2][0] = sRight;
- verts[1][2][1] = tTop;
-
- /* lower-right */
- verts[2][0][0] = x1;
- verts[2][0][1] = y1;
- verts[2][2][0] = sRight;
- verts[2][2][1] = tBot;
-
- /* lower-left */
- verts[3][0][0] = x0;
- verts[3][0][1] = y1;
- verts[3][2][0] = sLeft;
- verts[3][2][1] = tBot;
-
- /* same for all verts: */
- for (i = 0; i < 4; i++) {
- verts[i][0][2] = z; /*Z*/
- verts[i][0][3] = 1.0; /*W*/
- verts[i][1][0] = color[0];
- verts[i][1][1] = color[1];
- verts[i][1][2] = color[2];
- verts[i][1][3] = color[3];
- verts[i][2][2] = 0.0; /*R*/
- verts[i][2][3] = 1.0; /*Q*/
+
+ /* setup vertex data */
+ {
+ const struct gl_framebuffer *fb = st->ctx->DrawBuffer;
+ const GLfloat fb_width = fb->Width;
+ const GLfloat fb_height = fb->Height;
+ const GLfloat clip_x0 = x0 / fb_width * 2.0 - 1.0;
+ const GLfloat clip_y0 = y0 / fb_height * 2.0 - 1.0;
+ const GLfloat clip_x1 = x1 / fb_width * 2.0 - 1.0;
+ const GLfloat clip_y1 = y1 / fb_height * 2.0 - 1.0;
+ const GLfloat sLeft = 0.0F, sRight = 1.0F;
+ const GLfloat tTop = invertTex, tBot = 1.0 - tTop;
+ GLuint tex, i;
+
+ /* upper-left */
+ verts[0][0][0] = clip_x0; /* v[0].attr[0].x */
+ verts[0][0][1] = clip_y0; /* v[0].attr[0].y */
+
+ /* upper-right */
+ verts[1][0][0] = clip_x1;
+ verts[1][0][1] = clip_y0;
+
+ /* lower-right */
+ verts[2][0][0] = clip_x1;
+ verts[2][0][1] = clip_y1;
+
+ /* lower-left */
+ verts[3][0][0] = clip_x0;
+ verts[3][0][1] = clip_y1;
+
+ tex = color ? 2 : 1;
+ verts[0][tex][0] = sLeft; /* v[0].attr[tex].s */
+ verts[0][tex][1] = tTop; /* v[0].attr[tex].t */
+ verts[1][tex][0] = sRight;
+ verts[1][tex][1] = tTop;
+ verts[2][tex][0] = sRight;
+ verts[2][tex][1] = tBot;
+ verts[3][tex][0] = sLeft;
+ verts[3][tex][1] = tBot;
+
+ /* same for all verts: */
+ if (color) {
+ for (i = 0; i < 4; i++) {
+ verts[i][0][2] = z; /*Z*/
+ verts[i][0][3] = 1.0; /*W*/
+ verts[i][1][0] = color[0];
+ verts[i][1][1] = color[1];
+ verts[i][1][2] = color[2];
+ verts[i][1][3] = color[3];
+ verts[i][2][2] = 0.0; /*R*/
+ verts[i][2][3] = 1.0; /*Q*/
+ }
+ }
+ else {
+ for (i = 0; i < 4; i++) {
+ verts[i][0][2] = z; /*Z*/
+ verts[i][0][3] = 1.0; /*W*/
+ verts[i][1][2] = 0.0; /*R*/
+ verts[i][1][3] = 1.0; /*Q*/
+ }
+ }
}
- st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 3, GL_FALSE);
+ {
+ struct pipe_buffer *buf;
+ ubyte *map;
+
+ /* allocate/load buffer object with vertex data */
+ buf = pipe->winsys->buffer_create(pipe->winsys, 32,
+ PIPE_BUFFER_USAGE_VERTEX,
+ sizeof(verts));
+ map = pipe->winsys->buffer_map(pipe->winsys, buf,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
+ memcpy(map, verts, sizeof(verts));
+ pipe->winsys->buffer_unmap(pipe->winsys, buf);
+
+ util_draw_vertex_buffer(pipe, buf,
+ PIPE_PRIM_QUADS,
+ 4, /* verts */
+ 3); /* attribs/vert */
+
+ pipe->winsys->buffer_destroy(pipe->winsys, buf);
+ }
}
@@ -605,12 +603,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
x1 = x + width * ctx->Pixel.ZoomX;
y0 = y;
y1 = y + height * ctx->Pixel.ZoomY;
-
- /* draw textured quad */
- if (color)
- draw_quad_colored(ctx, x0, y0, z, x1, y1, color, invertTex);
- else
- draw_quad(ctx, x0, y0, z, x1, y1, invertTex);
+ draw_quad(ctx, x0, y0, z, x1, y1, color, invertTex);
/* restore state */
cso_restore_rasterizer(cso);
@@ -878,9 +871,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
GLsizei width, GLsizei height,
GLint dstx, GLint dsty)
{
- struct st_renderbuffer *rbRead = st_renderbuffer(ctx->ReadBuffer->_StencilBuffer);
struct st_renderbuffer *rbDraw = st_renderbuffer(ctx->DrawBuffer->_StencilBuffer);
- struct pipe_surface *psRead = rbRead->surface;
struct pipe_surface *psDraw = rbDraw->surface;
ubyte *drawMap;
ubyte *buffer;
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index b1a56f3ca63..69dde56e557 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -252,6 +252,8 @@ st_new_renderbuffer_fb(enum pipe_format format)
switch (format) {
case PIPE_FORMAT_A8R8G8B8_UNORM:
case PIPE_FORMAT_B8G8R8A8_UNORM:
+ case PIPE_FORMAT_X8R8G8B8_UNORM:
+ case PIPE_FORMAT_B8G8R8X8_UNORM:
case PIPE_FORMAT_A1R5G5B5_UNORM:
case PIPE_FORMAT_A4R4G4B4_UNORM:
case PIPE_FORMAT_R5G6B5_UNORM:
@@ -268,6 +270,8 @@ st_new_renderbuffer_fb(enum pipe_format format)
break;
case PIPE_FORMAT_S8Z24_UNORM:
case PIPE_FORMAT_Z24S8_UNORM:
+ case PIPE_FORMAT_X8Z24_UNORM:
+ case PIPE_FORMAT_Z24X8_UNORM:
strb->Base.InternalFormat = GL_DEPTH24_STENCIL8_EXT;
strb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT;
break;
@@ -396,6 +400,10 @@ st_finish_render_texture(GLcontext *ctx,
ctx->st->pipe->flush(ctx->st->pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
+ ctx->st->pipe->texture_update(ctx->st->pipe,
+ st_get_texobj_texture(att->Texture),
+ att->CubeMapFace, 1 << att->TextureLevel);
+
/*
printf("FINISH RENDER TO TEXTURE surf=%p\n", strb->surface);
*/
diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c
index 67f8b1f8ebb..a293ec3f0b9 100644
--- a/src/mesa/state_tracker/st_cb_program.c
+++ b/src/mesa/state_tracker/st_cb_program.c
@@ -39,7 +39,7 @@
#include "shader/programopt.h"
#include "shader/shader_api.h"
-#include "cso_cache/cso_cache.h"
+#include "cso_cache/cso_context.h"
#include "draw/draw_context.h"
#include "st_context.h"
@@ -127,7 +127,6 @@ void
st_delete_program(GLcontext *ctx, struct gl_program *prog)
{
struct st_context *st = st_context(ctx);
- struct pipe_context *pipe = st->pipe;
switch( prog->Target ) {
case GL_VERTEX_PROGRAM_ARB:
@@ -135,7 +134,7 @@ st_delete_program(GLcontext *ctx, struct gl_program *prog)
struct st_vertex_program *stvp = (struct st_vertex_program *) prog;
if (stvp->driver_shader) {
- pipe->delete_vs_state(pipe, stvp->driver_shader);
+ cso_delete_vertex_shader(st->cso_context, stvp->driver_shader);
stvp->driver_shader = NULL;
}
@@ -150,7 +149,7 @@ st_delete_program(GLcontext *ctx, struct gl_program *prog)
struct st_fragment_program *stfp = (struct st_fragment_program *) prog;
if (stfp->driver_shader) {
- pipe->delete_fs_state(pipe, stfp->driver_shader);
+ cso_delete_fragment_shader(st->cso_context, stfp->driver_shader);
stfp->driver_shader = NULL;
}
@@ -187,7 +186,6 @@ static void st_program_string_notify( GLcontext *ctx,
struct gl_program *prog )
{
struct st_context *st = st_context(ctx);
- struct pipe_context *pipe = st->pipe;
if (target == GL_FRAGMENT_PROGRAM_ARB) {
struct st_fragment_program *stfp = (struct st_fragment_program *) prog;
@@ -195,7 +193,7 @@ static void st_program_string_notify( GLcontext *ctx,
stfp->serialNo++;
if (stfp->driver_shader) {
- pipe->delete_fs_state(pipe, stfp->driver_shader);
+ cso_delete_fragment_shader(st->cso_context, stfp->driver_shader);
stfp->driver_shader = NULL;
}
@@ -215,7 +213,7 @@ static void st_program_string_notify( GLcontext *ctx,
stvp->serialNo++;
if (stvp->driver_shader) {
- pipe->delete_vs_state(pipe, stvp->driver_shader);
+ cso_delete_vertex_shader(st->cso_context, stvp->driver_shader);
stvp->driver_shader = NULL;
}
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 3db27902675..005bb2e54db 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -49,6 +49,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
#include "util/p_tile.h"
+#include "util/u_blit.h"
#define DBG if (0) printf
@@ -895,6 +896,11 @@ st_TexSubimage(GLcontext * ctx,
dstRowStride = stImage->surface->pitch * stImage->surface->cpp;
}
+ if (!texImage->Data) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage");
+ return;
+ }
+
src = (const GLubyte *) pixels;
for (i = 0; i++ < depth;) {
@@ -906,10 +912,11 @@ st_TexSubimage(GLcontext * ctx,
texImage->ImageOffsets,
width, height, 1,
format, type, src, packing)) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "st_TexSubImage");
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage");
}
if (stImage->pt && i < depth) {
+ /* map next slice of 3D texture */
st_texture_image_unmap(stImage);
texImage->Data = st_texture_image_map(ctx->st, stImage, zoffset + i);
src += srcImageStride;
@@ -1134,11 +1141,9 @@ do_copy_texsubimage(GLcontext *ctx,
dest_surface = screen->get_tex_surface(screen, stImage->pt, stImage->face,
stImage->level, destZ);
- if (src_format == dest_format &&
- ctx->_ImageTransferState == 0x0 &&
+ if (ctx->_ImageTransferState == 0x0 &&
strb->surface->buffer &&
- dest_surface->buffer &&
- strb->surface->cpp == stImage->pt->cpp) {
+ dest_surface->buffer) {
/* do blit-style copy */
/* XXX may need to invert image depending on window
@@ -1162,16 +1167,26 @@ do_copy_texsubimage(GLcontext *ctx,
GL_COPY); /* ? */
#else
- pipe->surface_copy(pipe,
- do_flip,
- /* dest */
- dest_surface,
- destX, destY,
- /* src */
- strb->surface,
- srcX, srcY,
- /* size */
- width, height);
+ if (src_format == dest_format) {
+ pipe->surface_copy(pipe,
+ do_flip,
+ /* dest */
+ dest_surface,
+ destX, destY,
+ /* src */
+ strb->surface,
+ srcX, srcY,
+ /* size */
+ width, height);
+ } else {
+ util_blit_pixels(ctx->st->blit,
+ strb->surface,
+ srcX, do_flip ? srcY + height : srcY,
+ srcX + width, do_flip ? srcY : srcY + height,
+ dest_surface,
+ destX, destY, destX + width, destY + height,
+ 0.0, PIPE_TEX_MIPFILTER_NEAREST);
+ }
#endif
}
else {
@@ -1358,7 +1373,7 @@ copy_image_data_to_texture(struct st_context *st,
pipe_texture_release(&stImage->pt);
}
- else {
+ else if (stImage->base.Data) {
assert(stImage->base.Data != NULL);
/* More straightforward upload.
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index dadc524b51a..8a30871fa07 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -176,22 +176,29 @@ static void st_destroy_context_priv( struct st_context *st )
}
}
- st->pipe->destroy( st->pipe );
free( st );
}
void st_destroy_context( struct st_context *st )
{
+ struct pipe_context *pipe = st->pipe;
+ struct cso_context *cso = st->cso_context;
GLcontext *ctx = st->ctx;
/* need to unbind and destroy CSO objects before anything else */
- cso_destroy_context(st->cso_context);
+ cso_release_all(st->cso_context);
_mesa_delete_program_cache(st->ctx, st->pixel_xfer.cache);
_mesa_free_context_data(ctx);
+
st_destroy_context_priv(st);
+
+ cso_destroy_context(cso);
+
+ pipe->destroy( pipe );
+
free(ctx);
}
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 2851770d4ca..80a71d17667 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -123,8 +123,6 @@ struct st_context
GLfloat polygon_offset_scale; /* ?? */
- GLfloat bitmap_texcoord_bias;
-
/** Mapping from VERT_RESULT_x to post-transformed vertex slot */
const GLuint *vertex_result_to_slot;
@@ -165,6 +163,8 @@ struct st_context
struct pipe_buffer *vbuf;
} clear;
+ void *passthrough_fs; /**< simple pass-through frag shader */
+
struct gen_mipmap_state *gen_mipmap;
struct blit_state *blit;
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index befcb96bd89..6c20120ac7a 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -190,6 +190,61 @@ pipe_vertex_format(GLenum type, GLuint size, GLboolean normalized)
}
+/*
+ * If edge flags are needed, setup an bitvector of flags and call
+ * pipe->set_edgeflags().
+ * XXX memleak: need to free the returned pointer at some point
+ */
+static void *
+setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count,
+ const struct gl_client_array *array)
+{
+ struct pipe_context *pipe = ctx->st->pipe;
+
+ if ((primMode == GL_TRIANGLES ||
+ primMode == GL_QUADS ||
+ primMode == GL_POLYGON) &&
+ (ctx->Polygon.FrontMode != GL_FILL ||
+ ctx->Polygon.BackMode != GL_FILL)) {
+ /* need edge flags */
+ GLuint i;
+ unsigned *vec;
+ struct st_buffer_object *stobj = st_buffer_object(array->BufferObj);
+ ubyte *map;
+
+ if (!stobj)
+ return NULL;
+
+ vec = (unsigned *) calloc(sizeof(unsigned), (count + 31) / 32);
+ if (!vec)
+ return NULL;
+
+ map = pipe->winsys->buffer_map(pipe->winsys, stobj->buffer,
+ PIPE_BUFFER_USAGE_CPU_READ);
+ map = ADD_POINTERS(map, array->Ptr);
+
+ for (i = 0; i < count; i++) {
+ if (*((float *) map))
+ vec[i/32] |= 1 << (i % 32);
+
+ map += array->StrideB;
+ }
+
+ pipe->winsys->buffer_unmap(pipe->winsys, stobj->buffer);
+
+ pipe->set_edgeflags(pipe, vec);
+
+ return vec;
+ }
+ else {
+ /* edge flags not needed */
+ pipe->set_edgeflags(pipe, NULL);
+ return NULL;
+ }
+}
+
+
+
/**
* This function gets plugged into the VBO module and is called when
* we have something to render.
@@ -277,7 +332,6 @@ st_draw_vbo(GLcontext *ctx,
pipe->set_vertex_buffers(pipe, vp->num_inputs, vbuffer);
pipe->set_vertex_elements(pipe, vp->num_inputs, velements);
-
/* do actual drawing */
if (ib) {
/* indexed primitive */
@@ -317,6 +371,10 @@ st_draw_vbo(GLcontext *ctx,
/* draw */
for (i = 0; i < nr_prims; i++) {
+ setup_edgeflags(ctx, prims[i].mode,
+ prims[i].start + indexOffset, prims[i].count,
+ arrays[VERT_ATTRIB_EDGEFLAG]);
+
pipe->draw_elements(pipe, indexBuf, indexSize,
prims[i].mode,
prims[i].start + indexOffset, prims[i].count);
@@ -328,6 +386,10 @@ st_draw_vbo(GLcontext *ctx,
/* non-indexed */
GLuint i;
for (i = 0; i < nr_prims; i++) {
+ setup_edgeflags(ctx, prims[i].mode,
+ prims[i].start, prims[i].count,
+ arrays[VERT_ATTRIB_EDGEFLAG]);
+
pipe->draw_arrays(pipe, prims[i].mode, prims[i].start, prims[i].count);
}
}
@@ -343,76 +405,6 @@ st_draw_vbo(GLcontext *ctx,
/**
- * Utility function for drawing simple primitives (such as quads for
- * glClear and glDrawPixels). Coordinates are in screen space.
- * \param mode one of PIPE_PRIM_x
- * \param numVertex number of vertices
- * \param verts vertex data (all attributes are float[4])
- * \param numAttribs number of attributes per vertex
- */
-void
-st_draw_vertices(GLcontext *ctx, unsigned prim,
- unsigned numVertex, float *verts,
- unsigned numAttribs,
- GLboolean inClipCoords)
-{
- const float width = ctx->DrawBuffer->Width;
- const float height = ctx->DrawBuffer->Height;
- const unsigned vertex_bytes = numVertex * numAttribs * 4 * sizeof(float);
- struct pipe_context *pipe = ctx->st->pipe;
- struct pipe_buffer *vbuf;
- struct pipe_vertex_buffer vbuffer;
- struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS];
- unsigned i;
-
- assert(numAttribs > 0);
-
- if (!inClipCoords) {
- /* convert to clip coords */
- for (i = 0; i < numVertex; i++) {
- float x = verts[i * numAttribs * 4 + 0];
- float y = verts[i * numAttribs * 4 + 1];
- x = x / width * 2.0 - 1.0;
- y = y / height * 2.0 - 1.0;
- verts[i * numAttribs * 4 + 0] = x;
- verts[i * numAttribs * 4 + 1] = y;
- }
- }
-
- /* XXX create one-time */
- vbuf = pipe->winsys->buffer_create(pipe->winsys, 32,
- PIPE_BUFFER_USAGE_VERTEX, vertex_bytes);
- assert(vbuf);
-
- memcpy(pipe->winsys->buffer_map(pipe->winsys, vbuf,
- PIPE_BUFFER_USAGE_CPU_WRITE),
- verts, vertex_bytes);
- pipe->winsys->buffer_unmap(pipe->winsys, vbuf);
-
- /* tell pipe about the vertex buffer */
- vbuffer.buffer = vbuf;
- vbuffer.pitch = numAttribs * 4 * sizeof(float); /* vertex size */
- vbuffer.buffer_offset = 0;
- pipe->set_vertex_buffers(pipe, 1, &vbuffer);
-
- /* tell pipe about the vertex attributes */
- for (i = 0; i < numAttribs; i++) {
- velements[i].src_offset = i * 4 * sizeof(GLfloat);
- velements[i].vertex_buffer_index = 0;
- velements[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
- velements[i].nr_components = 4;
- }
- pipe->set_vertex_elements(pipe, numAttribs, velements);
-
- /* draw */
- pipe->draw_arrays(pipe, prim, 0, numVertex);
-
- /* XXX: do one-time */
- pipe_buffer_reference(pipe->winsys, &vbuf, NULL);
-}
-
-
-/**
* Set the (private) draw module's post-transformed vertex format when in
* GL_SELECT or GL_FEEDBACK mode or for glRasterPos.
*/
diff --git a/src/mesa/state_tracker/st_draw.h b/src/mesa/state_tracker/st_draw.h
index 171bde57e55..c81f2b25dad 100644
--- a/src/mesa/state_tracker/st_draw.h
+++ b/src/mesa/state_tracker/st_draw.h
@@ -59,11 +59,4 @@ st_feedback_draw_vbo(GLcontext *ctx,
GLuint min_index,
GLuint max_index);
-void
-st_draw_vertices(GLcontext *ctx, unsigned prim,
- unsigned numVertex, float *verts,
- unsigned numAttribs,
- GLboolean inClipCoords);
-
-
#endif
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index f2d40e84b3c..260a2efe886 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -109,9 +109,6 @@ void st_init_limits(struct st_context *st)
c->MaxTextureLodBias
= screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_LOD_BIAS);
- st->bitmap_texcoord_bias
- = screen->get_paramf(screen, PIPE_CAP_BITMAP_TEXCOORD_BIAS);
-
c->MaxDrawBuffers
= CLAMP(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS),
1, MAX_DRAW_BUFFERS);
@@ -220,11 +217,12 @@ void st_init_extensions(struct st_context *st)
ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
}
+#if 01
if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
PIPE_TEXTURE)) {
ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE;
}
-
+#endif
if (screen->is_format_supported(screen, PIPE_FORMAT_YCBCR, PIPE_TEXTURE) ||
screen->is_format_supported(screen, PIPE_FORMAT_YCBCR_REV, PIPE_TEXTURE)) {
ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 3648ded8a1d..d450c306947 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -270,7 +270,7 @@ st_translate_vertex_program(struct st_context *st,
stvp->state.tokens = NULL;
}
if (stvp->driver_shader) {
- pipe->delete_vs_state(pipe, stvp->driver_shader);
+ cso_delete_vertex_shader(st->cso_context, stvp->driver_shader);
stvp->driver_shader = NULL;
}
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c
index 8e3235cc99d..66d81e2b959 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -290,8 +290,7 @@ st_texture_image_copy(struct pipe_context *pipe,
GLuint i;
/* XXX this is a hack */
- if (dst->compressed)
- height /= 4;
+ const GLuint copyHeight = dst->compressed ? height / 4 : height;
for (i = 0; i < depth; i++) {
GLuint srcLevel;
@@ -315,7 +314,7 @@ st_texture_image_copy(struct pipe_context *pipe,
0, 0, /* destX, Y */
src_surface,
0, 0, /* srcX, Y */
- width, height);
+ width, copyHeight);
pipe_surface_reference(&dst_surface, NULL);
pipe_surface_reference(&src_surface, NULL);
diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c
index fb04d9f746a..cbf66170588 100644
--- a/src/mesa/swrast/s_drawpix.c
+++ b/src/mesa/swrast/s_drawpix.c
@@ -877,7 +877,7 @@ end:
RENDER_FINISH(swrast,ctx);
- _mesa_unmap_drapix_pbo(ctx, unpack);
+ _mesa_unmap_drawpix_pbo(ctx, unpack);
}