summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/softpipe
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/pipe/softpipe')
-rw-r--r--src/mesa/pipe/softpipe/sp_prim_setup.c44
-rw-r--r--src/mesa/pipe/softpipe/sp_state_derived.c17
-rw-r--r--src/mesa/pipe/softpipe/sp_surface.c38
-rw-r--r--src/mesa/pipe/softpipe/sp_surface.h32
-rw-r--r--src/mesa/pipe/softpipe/sp_tex_sample.c1
-rw-r--r--src/mesa/pipe/softpipe/sp_texture.c36
-rw-r--r--src/mesa/pipe/softpipe/sp_texture.h34
7 files changed, 85 insertions, 117 deletions
diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c
index 89f8df945c..cdc385e4db 100644
--- a/src/mesa/pipe/softpipe/sp_prim_setup.c
+++ b/src/mesa/pipe/softpipe/sp_prim_setup.c
@@ -769,7 +769,7 @@ line_persp_coeff(struct setup_stage *setup,
{
/* XXX double-check/verify this arithmetic */
const float a0 = setup->vmin->data[vertSlot][i] * setup->vmin->data[0][3];
- const float a1 = setup->vmax->data[vertSlot][i] * setup->vmin->data[0][3];
+ const float a1 = setup->vmax->data[vertSlot][i] * setup->vmax->data[0][3];
const float da = a1 - a0;
const float dadx = da * setup->emaj.dx * setup->oneoverarea;
const float dady = da * setup->emaj.dy * setup->oneoverarea;
@@ -873,20 +873,9 @@ plot(struct setup_stage *setup, int x, int y)
/**
- * Determine whether or not to emit a line fragment by checking
- * line stipple pattern.
- */
-static INLINE unsigned
-stipple_test(int counter, ushort pattern, int factor)
-{
- int b = (counter / factor) & 0xf;
- return (1 << b) & pattern;
-}
-
-
-/**
* Do setup for line rasterization, then render the line.
- * XXX single-pixel width, no stipple, etc
+ * Single-pixel width, no stipple, etc. We rely on the 'draw' module
+ * to handle stippling and wide lines.
*/
static void
setup_line(struct draw_stage *stage, struct prim_header *prim)
@@ -894,8 +883,6 @@ setup_line(struct draw_stage *stage, struct prim_header *prim)
const struct vertex_header *v0 = prim->v[0];
const struct vertex_header *v1 = prim->v[1];
struct setup_stage *setup = setup_stage( stage );
- struct softpipe_context *sp = setup->softpipe;
-
int x0 = (int) v0->data[0][0];
int x1 = (int) v1->data[0][0];
int y0 = (int) v0->data[0][1];
@@ -947,12 +934,7 @@ setup_line(struct draw_stage *stage, struct prim_header *prim)
const int errorDec = error - dx;
for (i = 0; i < dx; i++) {
- if (!sp->rasterizer->line_stipple_enable ||
- stipple_test(sp->line_stipple_counter,
- (ushort) sp->rasterizer->line_stipple_pattern,
- sp->rasterizer->line_stipple_factor + 1)) {
- plot(setup, x0, y0);
- }
+ plot(setup, x0, y0);
x0 += xstep;
if (error < 0) {
@@ -962,8 +944,6 @@ setup_line(struct draw_stage *stage, struct prim_header *prim)
error += errorDec;
y0 += ystep;
}
-
- sp->line_stipple_counter++;
}
}
else {
@@ -974,15 +954,9 @@ setup_line(struct draw_stage *stage, struct prim_header *prim)
const int errorDec = error - dy;
for (i = 0; i < dy; i++) {
- if (!sp->rasterizer->line_stipple_enable ||
- stipple_test(sp->line_stipple_counter,
- (ushort) sp->rasterizer->line_stipple_pattern,
- sp->rasterizer->line_stipple_factor + 1)) {
- plot(setup, x0, y0);
- }
+ plot(setup, x0, y0);
y0 += ystep;
-
if (error < 0) {
error += errorInc;
}
@@ -990,8 +964,6 @@ setup_line(struct draw_stage *stage, struct prim_header *prim)
error += errorDec;
x0 += xstep;
}
-
- sp->line_stipple_counter++;
}
}
@@ -1234,8 +1206,6 @@ static void setup_end( struct draw_stage *stage )
static void reset_stipple_counter( struct draw_stage *stage )
{
- struct setup_stage *setup = setup_stage(stage);
- setup->softpipe->line_stipple_counter = 0;
}
@@ -1341,8 +1311,8 @@ void sp_vbuf_render( struct pipe_context *pipe,
break;
case PIPE_PRIM_POINTS:
- for (i = 0; i < nr_elements; i += 2) {
- prim.v[i] = (struct vertex_header *)((char *)vertex_buffer +
+ for (i = 0; i < nr_elements; i++) {
+ prim.v[0] = (struct vertex_header *)((char *)vertex_buffer +
elements[i] * vertex_size);
setup->stage.point( &setup->stage, &prim );
}
diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c
index 630ae3163f..0f1410e5de 100644
--- a/src/mesa/pipe/softpipe/sp_state_derived.c
+++ b/src/mesa/pipe/softpipe/sp_state_derived.c
@@ -48,6 +48,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
boolean emitBack0 = FALSE, emitBack1 = FALSE, emitPsize = FALSE;
uint front0 = 0, back0 = 0, front1 = 0, back1 = 0;
uint i;
+ int src = 0;
memset(vinfo, 0, sizeof(*vinfo));
@@ -61,7 +62,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
softpipe->psize_slot = -1;
/* always emit vertex pos */
- draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_LINEAR);
+ draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_LINEAR, src++);
/*
* XXX I think we need to reconcile the vertex shader outputs with
@@ -82,11 +83,11 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
case TGSI_SEMANTIC_COLOR:
if (vs->output_semantic_index[i] == 0) {
- front0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp);
+ front0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src++);
}
else {
assert(vs->output_semantic_index[i] == 1);
- front1 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp);
+ front1 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src++);
}
break;
@@ -101,7 +102,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
break;
case TGSI_SEMANTIC_FOG:
- draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_PERSPECTIVE);
+ draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_PERSPECTIVE, src++);
break;
case TGSI_SEMANTIC_PSIZE:
@@ -113,7 +114,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
case TGSI_SEMANTIC_GENERIC:
/* this includes texcoords and varying vars */
- draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE);
+ draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE, src++);
break;
default:
@@ -128,14 +129,14 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
* up 1:1 with the fragment shader inputs.
*/
if (emitBack0) {
- back0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp);
+ back0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src++);
}
if (emitBack1) {
- back1 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp);
+ back1 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src++);
}
if (emitPsize) {
softpipe->psize_slot
- = draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_CONSTANT);
+ = draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_CONSTANT, src++);
}
/* If the attributes have changed, tell the draw module about
diff --git a/src/mesa/pipe/softpipe/sp_surface.c b/src/mesa/pipe/softpipe/sp_surface.c
index d5119654ed..e115705507 100644
--- a/src/mesa/pipe/softpipe/sp_surface.c
+++ b/src/mesa/pipe/softpipe/sp_surface.c
@@ -32,44 +32,6 @@
#include "pipe/util/p_tile.h"
#include "sp_context.h"
#include "sp_surface.h"
-#include "sp_texture.h"
-
-
-/**
- * Called via pipe->get_tex_surface()
- * XXX is this in the right place?
- */
-struct pipe_surface *
-softpipe_get_tex_surface(struct pipe_context *pipe,
- struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice)
-{
- struct softpipe_texture *spt = softpipe_texture(pt);
- struct pipe_surface *ps;
-
- ps = pipe->winsys->surface_alloc(pipe->winsys);
- if (ps) {
- assert(ps->refcount);
- assert(ps->winsys);
- pipe->winsys->buffer_reference(pipe->winsys, &ps->buffer, spt->buffer);
- ps->format = pt->format;
- ps->cpp = pt->cpp;
- ps->width = pt->width[level];
- ps->height = pt->height[level];
- ps->pitch = ps->width;
- ps->offset = spt->level_offset[level];
-
- if (pt->target == PIPE_TEXTURE_CUBE || pt->target == PIPE_TEXTURE_3D) {
- ps->offset += ((pt->target == PIPE_TEXTURE_CUBE) ? face : zslice) *
- (pt->compressed ? ps->height/4 : ps->height) *
- ps->width * ps->cpp;
- } else {
- assert(face == 0);
- assert(zslice == 0);
- }
- }
- return ps;
-}
/* Upload data to a rectangular sub-region. Lots of choices how to do this:
diff --git a/src/mesa/pipe/softpipe/sp_surface.h b/src/mesa/pipe/softpipe/sp_surface.h
index b652e7598e..22de3ba43f 100644
--- a/src/mesa/pipe/softpipe/sp_surface.h
+++ b/src/mesa/pipe/softpipe/sp_surface.h
@@ -31,40 +31,8 @@
#ifndef SP_SURFACE_H
#define SP_SURFACE_H
-#include "sp_headers.h"
-#include "pipe/p_state.h"
-struct pipe_context;
struct softpipe_context;
-struct softpipe_tile_cache;
-
-
-extern struct pipe_surface *
-softpipe_get_tex_surface(struct pipe_context *pipe,
- struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice);
-
-
-extern void
-softpipe_get_tile(struct pipe_context *pipe, struct pipe_surface *ps,
- uint x, uint y, uint w, uint h, void *p, int dst_stride);
-
-extern void
-softpipe_put_tile(struct pipe_context *pipe, struct pipe_surface *ps,
- uint x, uint y, uint w, uint h,
- const void *p, int src_stride);
-
-extern void
-softpipe_get_tile_rgba(struct pipe_context *pipe,
- struct pipe_surface *ps,
- uint x, uint y, uint w, uint h,
- float *p);
-
-extern void
-softpipe_put_tile_rgba(struct pipe_context *pipe,
- struct pipe_surface *ps,
- uint x, uint y, uint w, uint h,
- const float *p);
extern void
diff --git a/src/mesa/pipe/softpipe/sp_tex_sample.c b/src/mesa/pipe/softpipe/sp_tex_sample.c
index 9e48ed0cd2..5e215c433a 100644
--- a/src/mesa/pipe/softpipe/sp_tex_sample.c
+++ b/src/mesa/pipe/softpipe/sp_tex_sample.c
@@ -33,6 +33,7 @@
*/
#include "sp_context.h"
+#include "sp_headers.h"
#include "sp_surface.h"
#include "sp_tex_sample.h"
#include "sp_tile_cache.h"
diff --git a/src/mesa/pipe/softpipe/sp_texture.c b/src/mesa/pipe/softpipe/sp_texture.c
index 532bcfcc51..d43a6996e9 100644
--- a/src/mesa/pipe/softpipe/sp_texture.c
+++ b/src/mesa/pipe/softpipe/sp_texture.c
@@ -130,3 +130,39 @@ softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
}
*pt = NULL;
}
+
+
+/**
+ * Called via pipe->get_tex_surface()
+ */
+struct pipe_surface *
+softpipe_get_tex_surface(struct pipe_context *pipe,
+ struct pipe_texture *pt,
+ unsigned face, unsigned level, unsigned zslice)
+{
+ struct softpipe_texture *spt = softpipe_texture(pt);
+ struct pipe_surface *ps;
+
+ ps = pipe->winsys->surface_alloc(pipe->winsys);
+ if (ps) {
+ assert(ps->refcount);
+ assert(ps->winsys);
+ pipe->winsys->buffer_reference(pipe->winsys, &ps->buffer, spt->buffer);
+ ps->format = pt->format;
+ ps->cpp = pt->cpp;
+ ps->width = pt->width[level];
+ ps->height = pt->height[level];
+ ps->pitch = ps->width;
+ ps->offset = spt->level_offset[level];
+
+ if (pt->target == PIPE_TEXTURE_CUBE || pt->target == PIPE_TEXTURE_3D) {
+ ps->offset += ((pt->target == PIPE_TEXTURE_CUBE) ? face : zslice) *
+ (pt->compressed ? ps->height/4 : ps->height) *
+ ps->width * ps->cpp;
+ } else {
+ assert(face == 0);
+ assert(zslice == 0);
+ }
+ }
+ return ps;
+}
diff --git a/src/mesa/pipe/softpipe/sp_texture.h b/src/mesa/pipe/softpipe/sp_texture.h
index e1a5db2791..0494bf365b 100644
--- a/src/mesa/pipe/softpipe/sp_texture.h
+++ b/src/mesa/pipe/softpipe/sp_texture.h
@@ -1,3 +1,30 @@
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * 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, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
#ifndef SP_TEXTURE_H
#define SP_TEXTURE_H
@@ -34,7 +61,10 @@ softpipe_texture_create(struct pipe_context *pipe, struct pipe_texture **pt);
extern void
softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt);
-
-#endif /* SP_TEXTURE */
+extern struct pipe_surface *
+softpipe_get_tex_surface(struct pipe_context *pipe,
+ struct pipe_texture *pt,
+ unsigned face, unsigned level, unsigned zslice);
+#endif /* SP_TEXTURE */