summaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe/softpipe
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-08-01 12:58:38 -0600
committerBrian <[email protected]>2007-08-01 12:58:38 -0600
commitfb206809ba2a131fd9034e10a00592f2d0d81fce (patch)
tree16f5f207e20fdb15e69d6bdca9b078fb425cbe04 /src/mesa/pipe/softpipe
parente99b673cb062a2fead92d1d7d373926d148ade71 (diff)
Checkpoint: glClear changes - working, bug very rough.
Diffstat (limited to 'src/mesa/pipe/softpipe')
-rw-r--r--src/mesa/pipe/softpipe/sp_clear.c90
-rw-r--r--src/mesa/pipe/softpipe/sp_region.c55
2 files changed, 130 insertions, 15 deletions
diff --git a/src/mesa/pipe/softpipe/sp_clear.c b/src/mesa/pipe/softpipe/sp_clear.c
index e83bc053ef7..40b1156715a 100644
--- a/src/mesa/pipe/softpipe/sp_clear.c
+++ b/src/mesa/pipe/softpipe/sp_clear.c
@@ -30,42 +30,102 @@
*/
+#include "pipe/p_defines.h"
#include "sp_clear.h"
#include "sp_context.h"
#include "sp_surface.h"
#include "colormac.h"
+static GLuint
+color_value(GLuint format, const GLfloat color[4])
+{
+ GLubyte r, g, b, a;
+
+ UNCLAMPED_FLOAT_TO_UBYTE(r, color[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(g, color[1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(b, color[2]);
+ UNCLAMPED_FLOAT_TO_UBYTE(a, color[3]);
+
+ switch (format) {
+ case PIPE_FORMAT_U_R8_G8_B8_A8:
+ return (r << 24) | (g << 16) | (b << 8) | a;
+ case PIPE_FORMAT_U_A8_R8_G8_B8:
+ return (a << 24) | (r << 16) | (g << 8) | b;
+ case PIPE_FORMAT_U_R5_G6_B5:
+ return ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
+ default:
+ return 0;
+ }
+}
+
+
void
softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth,
GLboolean stencil, GLboolean accum)
{
const struct softpipe_context *softpipe = softpipe_context(pipe);
- const GLint x = softpipe->scissor.minx;
- const GLint y = softpipe->scissor.miny;
- const GLint w = softpipe->scissor.maxx - x;
- const GLint h = softpipe->scissor.maxy - y;
+ const GLint x = softpipe->cliprect.minx;
+ const GLint y = softpipe->cliprect.miny;
+ const GLint w = softpipe->cliprect.maxx - x;
+ const GLint h = softpipe->cliprect.maxy - y;
if (color) {
GLuint i;
- GLubyte clr[4];
-
- UNCLAMPED_FLOAT_TO_UBYTE(clr[0], softpipe->clear_color.color[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(clr[1], softpipe->clear_color.color[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(clr[2], softpipe->clear_color.color[2]);
- UNCLAMPED_FLOAT_TO_UBYTE(clr[3], softpipe->clear_color.color[3]);
-
for (i = 0; i < softpipe->framebuffer.num_cbufs; i++) {
struct pipe_surface *ps = softpipe->framebuffer.cbufs[i];
- struct softpipe_surface *sps = softpipe_surface(ps);
- GLint j;
- for (j = 0; j < h; j++) {
- sps->write_mono_row_ub(sps, w, x, y + j, clr);
+
+ if (softpipe->blend.colormask == (PIPE_MASK_R | PIPE_MASK_G |
+ PIPE_MASK_B | PIPE_MASK_A)) {
+ /* no masking */
+ GLuint clearVal = color_value(ps->format,
+ softpipe->clear_color.color);
+ pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal);
+ }
+ else {
+ /* masking */
+
+ /*
+ for (j = 0; j < h; j++) {
+ sps->write_mono_row_ub(sps, w, x, y + j, clr);
+ }
+ */
}
}
}
if (depth) {
+ struct pipe_surface *ps = softpipe->framebuffer.zbuf;
+ GLuint clearVal;
+
+ switch (ps->format) {
+ case PIPE_FORMAT_U_Z16:
+ clearVal = (GLuint) (softpipe->depth_test.clear * 65535.0);
+ break;
+ case PIPE_FORMAT_U_Z32:
+ clearVal = (GLuint) (softpipe->depth_test.clear * 0xffffffff);
+ break;
+ case PIPE_FORMAT_Z24_S8:
+ clearVal = (GLuint) (softpipe->depth_test.clear * 0xffffff);
+ break;
+ default:
+ assert(0);
+ }
+
+ pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal);
}
+ if (stencil) {
+ struct pipe_surface *ps = softpipe->framebuffer.sbuf;
+ GLuint clearVal = softpipe->stencil.clear_value;
+ if (softpipe->stencil.write_mask[0] /*== 0xff*/) {
+ /* no masking */
+ pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal);
+ }
+ else if (softpipe->stencil.write_mask[0] != 0x0) {
+ /* masking */
+ /* fill with quad funcs */
+ assert(0);
+ }
+ }
}
diff --git a/src/mesa/pipe/softpipe/sp_region.c b/src/mesa/pipe/softpipe/sp_region.c
index 04ae5e94f9e..4d8b35d3e71 100644
--- a/src/mesa/pipe/softpipe/sp_region.c
+++ b/src/mesa/pipe/softpipe/sp_region.c
@@ -92,6 +92,59 @@ sp_region_unmap(struct pipe_context *pipe, struct pipe_region *region)
}
+
+static GLubyte *
+get_pointer(struct pipe_region *dst, GLuint x, GLuint y)
+{
+ return dst->map + (y * dst->pitch + x) * dst->cpp;
+}
+
+
+static void
+sp_region_fill(struct pipe_context *pipe,
+ struct pipe_region *dst,
+ GLuint dst_offset,
+ GLuint dstx, GLuint dsty,
+ GLuint width, GLuint height, GLuint value)
+{
+ GLuint i, j;
+ switch (dst->cpp) {
+ case 1:
+ {
+ GLubyte *row = get_pointer(dst, dstx, dsty);
+ for (i = 0; i < height; i++) {
+ memset(row, value, width);
+ row += dst->pitch;
+ }
+ }
+ break;
+ case 2:
+ {
+ GLushort *row = (GLushort *) get_pointer(dst, dstx, dsty);
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++)
+ row[j] = value;
+ row += dst->pitch;
+ }
+ }
+ break;
+ case 4:
+ {
+ GLuint *row = (GLuint *) get_pointer(dst, dstx, dsty);
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++)
+ row[j] = value;
+ row += dst->pitch;
+ }
+ }
+ break;
+ default:
+ assert(0);
+
+ }
+}
+
+
void
sp_init_region_functions(struct softpipe_context *sp)
{
@@ -101,5 +154,7 @@ sp_init_region_functions(struct softpipe_context *sp)
sp->pipe.region_map = sp_region_map;
sp->pipe.region_unmap = sp_region_unmap;
+ sp->pipe.region_fill = sp_region_fill;
+
/* XXX lots of other region functions needed... */
}