summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/i915tex
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri/i915tex')
-rw-r--r--src/mesa/drivers/dri/i915tex/Makefile1
-rw-r--r--src/mesa/drivers/dri/i915tex/i915_context.c2
-rw-r--r--src/mesa/drivers/dri/i915tex/i915_vtbl.c1
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_buffers.c12
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_context.c69
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_fbo.c18
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_fbo.h10
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_surface.c259
8 files changed, 339 insertions, 33 deletions
diff --git a/src/mesa/drivers/dri/i915tex/Makefile b/src/mesa/drivers/dri/i915tex/Makefile
index b218929dce..827acc0c46 100644
--- a/src/mesa/drivers/dri/i915tex/Makefile
+++ b/src/mesa/drivers/dri/i915tex/Makefile
@@ -48,6 +48,7 @@ DRIVER_SOURCES = \
intel_screen.c \
intel_span.c \
intel_state.c \
+ intel_surface.c \
intel_tris.c \
intel_fbo.c \
intel_depthstencil.c \
diff --git a/src/mesa/drivers/dri/i915tex/i915_context.c b/src/mesa/drivers/dri/i915tex/i915_context.c
index 49e30141e4..b6d004b258 100644
--- a/src/mesa/drivers/dri/i915tex/i915_context.c
+++ b/src/mesa/drivers/dri/i915tex/i915_context.c
@@ -71,6 +71,8 @@ i915InvalidateState(GLcontext * ctx, GLuint new_state)
_tnl_invalidate_vertex_state(ctx, new_state);
intel_context(ctx)->NewGLState |= new_state;
+ st_invalidate_state(ctx, new_state);
+
/* Todo: gather state values under which tracked parameters become
* invalidated, add callbacks for things like
* ProgramLocalParameters, etc.
diff --git a/src/mesa/drivers/dri/i915tex/i915_vtbl.c b/src/mesa/drivers/dri/i915tex/i915_vtbl.c
index 13ca9aee6b..cc74ceae18 100644
--- a/src/mesa/drivers/dri/i915tex/i915_vtbl.c
+++ b/src/mesa/drivers/dri/i915tex/i915_vtbl.c
@@ -66,6 +66,7 @@ i915_reduced_primitive_state(struct intel_context *intel, GLenum rprim)
st1 &= ~ST1_ENABLE;
switch (rprim) {
+ case GL_QUADS: /* from RASTERIZE(GL_QUADS) in t_dd_tritemp.h */
case GL_TRIANGLES:
if (intel->ctx.Polygon.StippleFlag && intel->hw_stipple)
st1 |= ST1_ENABLE;
diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c
index 4b2a4acaf9..72c7b5ae45 100644
--- a/src/mesa/drivers/dri/i915tex/intel_buffers.c
+++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c
@@ -250,7 +250,8 @@ intelWindowMoved(struct intel_context *intel)
flags = intel_fb->vblank_flags & ~VBLANK_FLAG_SECONDARY;
}
- if (flags != intel_fb->vblank_flags) {
+ if (flags != intel_fb->vblank_flags && intel_fb->vblank_flags &&
+ !(intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ)) {
drmVBlank vbl;
int i;
@@ -261,7 +262,9 @@ intelWindowMoved(struct intel_context *intel)
}
for (i = 0; i < intel_fb->pf_num_pages; i++) {
- if (!intel_fb->color_rb[i])
+ if (!intel_fb->color_rb[i] ||
+ (intel_fb->vbl_waited - intel_fb->color_rb[i]->vbl_pending) <=
+ (1<<23))
continue;
vbl.request.sequence = intel_fb->color_rb[i]->vbl_pending;
@@ -583,8 +586,9 @@ intelScheduleSwap(const __DRIdrawablePrivate * dPriv, GLboolean *missed_target)
drm_i915_vblank_swap_t swap;
GLboolean ret;
- if ((intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ) ||
- intelScreen->drmMinor < (intel_fb->pf_active ? 9 : 6))
+ if (!intel_fb->vblank_flags ||
+ (intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ) ||
+ intelScreen->drmMinor < (intel_fb->pf_active ? 9 : 6))
return GL_FALSE;
swap.seqtype = DRM_VBLANK_ABSOLUTE;
diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c
index f032c97dfb..5ab919ecb6 100644
--- a/src/mesa/drivers/dri/i915tex/intel_context.c
+++ b/src/mesa/drivers/dri/i915tex/intel_context.c
@@ -60,6 +60,10 @@
#include "intel_buffer_objects.h"
#include "intel_fbo.h"
+#include "pipe/softpipe/sp_context.h"
+#include "state_tracker/st_public.h"
+
+
#include "drirenderbuffer.h"
#include "vblank.h"
#include "utils.h"
@@ -257,6 +261,9 @@ intelInvalidateState(GLcontext * ctx, GLuint new_state)
_vbo_InvalidateState(ctx, new_state);
_tnl_InvalidateState(ctx, new_state);
_tnl_invalidate_vertex_state(ctx, new_state);
+
+ st_invalidate_state( ctx, new_state );
+
intel_context(ctx)->NewGLState |= new_state;
}
@@ -504,6 +511,11 @@ intelInitContext(struct intel_context *intel,
FALLBACK(intel, INTEL_FALLBACK_USER, 1);
}
+
+ st_create_context( &intel->ctx,
+ softpipe_create() );
+
+
return GL_TRUE;
}
@@ -605,12 +617,23 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
if (intel->ctx.DrawBuffer == &intel_fb->Base) {
if (intel->driDrawable != driDrawPriv) {
- intel_fb->vblank_flags = (intel->intelScreen->irq_active != 0)
- ? driGetDefaultVBlankFlags(&intel->optionCache)
- : VBLANK_FLAG_NO_IRQ;
- (*dri_interface->getUST) (&intel_fb->swap_ust);
- driDrawableInitVBlank(driDrawPriv, intel_fb->vblank_flags,
- &intel_fb->vbl_seq);
+ if (driDrawPriv->pdraw->swap_interval == (unsigned)-1) {
+ int i;
+
+ intel_fb->vblank_flags = (intel->intelScreen->irq_active != 0)
+ ? driGetDefaultVBlankFlags(&intel->optionCache)
+ : VBLANK_FLAG_NO_IRQ;
+
+ (*dri_interface->getUST) (&intel_fb->swap_ust);
+ driDrawableInitVBlank(driDrawPriv, intel_fb->vblank_flags,
+ &intel_fb->vbl_seq);
+ intel_fb->vbl_waited = intel_fb->vbl_seq;
+
+ for (i = 0; i < 2; i++) {
+ if (intel_fb->color_rb[i])
+ intel_fb->color_rb[i]->vbl_pending = intel_fb->vbl_seq;
+ }
+ }
}
}
@@ -660,37 +683,27 @@ intelContendedLock(struct intel_context *intel, GLuint flags)
if (sarea->width != intel->width ||
sarea->height != intel->height ||
sarea->rotation != intel->current_rotation) {
-
- void *batchMap = intel->batch->map;
-
+ int numClipRects = intel->numClipRects;
+
/*
* FIXME: Really only need to do this when drawing to a
* common back- or front buffer.
*/
/*
- * This will drop the outstanding batchbuffer on the floor
+ * This will essentially drop the outstanding batchbuffer on the floor.
*/
+ intel->numClipRects = 0;
- if (batchMap != NULL) {
- driBOUnmap(intel->batch->buffer);
- intel->batch->map = NULL;
- }
-
- intel_batchbuffer_reset(intel->batch);
+ if (intel->Fallback)
+ _swrast_flush(&intel->ctx);
- if (batchMap == NULL) {
- driBOUnmap(intel->batch->buffer);
- intel->batch->map = NULL;
- }
+ INTEL_FIREVERTICES(intel);
- /* lose all primitives */
- intel->prim.primitive = ~0;
- intel->prim.start_ptr = 0;
- intel->prim.flush = 0;
+ if (intel->batch->map != intel->batch->ptr)
+ intel_batchbuffer_flush(intel->batch);
- /* re-emit all state */
- intel->vtbl.lost_hardware(intel);
+ intel->numClipRects = numClipRects;
/* force window update */
intel->lastStamp = 0;
@@ -724,7 +737,9 @@ void LOCK_HARDWARE( struct intel_context *intel )
BUFFER_BACK_LEFT);
}
- if (intel_rb && (intel_fb->vbl_waited - intel_rb->vbl_pending) > (1<<23)) {
+ if (intel_rb && intel_fb->vblank_flags &&
+ !(intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ) &&
+ (intel_fb->vbl_waited - intel_rb->vbl_pending) > (1<<23)) {
drmVBlank vbl;
vbl.request.type = DRM_VBLANK_ABSOLUTE;
diff --git a/src/mesa/drivers/dri/i915tex/intel_fbo.c b/src/mesa/drivers/dri/i915tex/intel_fbo.c
index 04ca5ae8ba..559788f20a 100644
--- a/src/mesa/drivers/dri/i915tex/intel_fbo.c
+++ b/src/mesa/drivers/dri/i915tex/intel_fbo.c
@@ -291,6 +291,12 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
rb->Width = width;
rb->Height = height;
+#if 1
+ /* update the surface's size too */
+ rb->surface->width = width;
+ rb->surface->height = height;
+#endif
+
/* This sets the Get/PutRow/Value functions */
intel_set_span_functions(&irb->Base);
@@ -362,7 +368,9 @@ intel_new_renderbuffer_fb(GLuint intFormat)
irb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT;
break;
default:
- assert(0);
+ _mesa_problem(NULL,
+ "Unexpected intFormat in intel_create_renderbuffer");
+ return NULL;
}
/* intel-specific methods */
@@ -371,7 +379,10 @@ intel_new_renderbuffer_fb(GLuint intFormat)
irb->Base.GetPointer = intel_get_pointer;
/* span routines set in alloc_storage function */
- return irb;
+ irb->Base.surface = intel_new_surface(intFormat);
+ irb->Base.surface->rb = irb;
+
+ return &irb->Base;
}
/**
@@ -399,6 +410,9 @@ intel_new_renderbuffer(GLcontext * ctx, GLuint name)
irb->Base.GetPointer = intel_get_pointer;
/* span routines set in alloc_storage function */
+ irb->Base.surface = intel_new_surface(0 /*unknown format*/);
+ irb->Base.surface->rb = irb;
+
return &irb->Base;
}
diff --git a/src/mesa/drivers/dri/i915tex/intel_fbo.h b/src/mesa/drivers/dri/i915tex/intel_fbo.h
index 762aac594e..7dc3967533 100644
--- a/src/mesa/drivers/dri/i915tex/intel_fbo.h
+++ b/src/mesa/drivers/dri/i915tex/intel_fbo.h
@@ -29,9 +29,14 @@
#define INTEL_FBO_H
+#include "pipe/p_state.h"
+#include "pipe/softpipe/sp_surface.h"
+
+
struct intel_context;
struct intel_region;
+
/**
* Intel framebuffer, derived from gl_framebuffer.
*/
@@ -82,6 +87,8 @@ struct intel_renderbuffer
GLuint pf_pending; /**< sequence number of pending flip */
GLuint vbl_pending; /**< vblank sequence number of pending flip */
+
+ struct intel_surface *surface;
};
#if 0
@@ -113,5 +120,8 @@ extern struct intel_region *intel_get_rb_region(struct gl_framebuffer *fb,
+extern struct pipe_surface *
+intel_new_surface(GLuint intFormat);
+
#endif /* INTEL_FBO_H */
diff --git a/src/mesa/drivers/dri/i915tex/intel_surface.c b/src/mesa/drivers/dri/i915tex/intel_surface.c
new file mode 100644
index 0000000000..043c5aa5fe
--- /dev/null
+++ b/src/mesa/drivers/dri/i915tex/intel_surface.c
@@ -0,0 +1,259 @@
+#include "glheader.h"
+#include "context.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
+#include "utils.h"
+#include "main/macros.h"
+
+
+#include "intel_screen.h"
+
+#include "intel_context.h"
+#include "intel_buffers.h"
+#include "intel_regions.h"
+#include "intel_span.h"
+#include "intel_fbo.h"
+
+#include "pipe/p_state.h"
+#include "pipe/p_defines.h"
+#include "pipe/softpipe/sp_surface.h"
+
+
+/*
+ * XXX a lof of this is a temporary kludge
+ */
+
+/**
+ * Note: the arithmetic/addressing in these functions is a little
+ * tricky since we need to invert the Y axis.
+ */
+
+
+static void
+read_quad_f_swz(struct softpipe_surface *sps, GLint x, GLint y,
+ GLfloat (*rrrr)[QUAD_SIZE])
+{
+ const GLint bytesPerRow = sps->surface.stride * sps->surface.cpp;
+ const GLint invY = sps->surface.height - y - 1;
+ const GLubyte *src = sps->surface.ptr + invY * bytesPerRow + x * sps->surface.cpp;
+ GLfloat *dst = (GLfloat *) rrrr;
+ GLubyte temp[16];
+ GLuint j;
+
+ assert(sps->surface.format == PIPE_FORMAT_U_A8_R8_G8_B8);
+
+ memcpy(temp + 8, src, 8);
+ memcpy(temp + 0, src + bytesPerRow, 8);
+
+ for (j = 0; j < 4; j++) {
+ dst[0 * 4 + j] = UBYTE_TO_FLOAT(temp[j * 4 + 2]); /*R*/
+ dst[1 * 4 + j] = UBYTE_TO_FLOAT(temp[j * 4 + 1]); /*G*/
+ dst[2 * 4 + j] = UBYTE_TO_FLOAT(temp[j * 4 + 0]); /*B*/
+ dst[3 * 4 + j] = UBYTE_TO_FLOAT(temp[j * 4 + 3]); /*A*/
+ }
+}
+
+
+static void
+write_quad_f_swz(struct softpipe_surface *sps, GLint x, GLint y,
+ GLfloat (*rrrr)[QUAD_SIZE])
+{
+ const GLfloat *src = (const GLfloat *) rrrr;
+ const GLint bytesPerRow = sps->surface.stride * sps->surface.cpp;
+ const GLint invY = sps->surface.height - y - 1;
+ GLubyte *dst = sps->surface.ptr + invY * bytesPerRow + x * sps->surface.cpp;
+ GLubyte temp[16];
+ GLuint j;
+
+ assert(sps->surface.format == PIPE_FORMAT_U_A8_R8_G8_B8);
+
+ for (j = 0; j < 4; j++) {
+ UNCLAMPED_FLOAT_TO_UBYTE(temp[j * 4 + 2], src[0 * 4 + j]); /*R*/
+ UNCLAMPED_FLOAT_TO_UBYTE(temp[j * 4 + 1], src[1 * 4 + j]); /*G*/
+ UNCLAMPED_FLOAT_TO_UBYTE(temp[j * 4 + 0], src[2 * 4 + j]); /*B*/
+ UNCLAMPED_FLOAT_TO_UBYTE(temp[j * 4 + 3], src[3 * 4 + j]); /*A*/
+ }
+
+ memcpy(dst, temp + 8, 8);
+ memcpy(dst + bytesPerRow, temp + 0, 8);
+}
+
+
+
+static void
+read_quad_z24(struct softpipe_surface *sps,
+ GLint x, GLint y, GLuint zzzz[QUAD_SIZE])
+{
+ static const GLuint mask = 0xffffff;
+ const GLint invY = sps->surface.height - y - 1;
+ const GLuint *src
+ = (GLuint *) (sps->surface.ptr
+ + (invY * sps->surface.stride + x) * sps->surface.cpp);
+
+ assert(sps->surface.format == PIPE_FORMAT_Z24_S8);
+
+ /* extract lower three bytes */
+ zzzz[0] = src[0] & mask;
+ zzzz[1] = src[1] & mask;
+ zzzz[2] = src[-sps->surface.stride] & mask;
+ zzzz[3] = src[-sps->surface.stride + 1] & mask;
+}
+
+static void
+write_quad_z24(struct softpipe_surface *sps,
+ GLint x, GLint y, const GLuint zzzz[QUAD_SIZE])
+{
+ static const GLuint mask = 0xff000000;
+ const GLint invY = sps->surface.height - y - 1;
+ GLuint *dst
+ = (GLuint *) (sps->surface.ptr
+ + (invY * sps->surface.stride + x) * sps->surface.cpp);
+
+ assert(sps->surface.format == PIPE_FORMAT_Z24_S8);
+
+ /* write lower three bytes */
+ dst[0] = (dst[0] & mask) | zzzz[0];
+ dst[1] = (dst[1] & mask) | zzzz[1];
+ dst -= sps->surface.stride;
+ dst[0] = (dst[0] & mask) | zzzz[2];
+ dst[1] = (dst[1] & mask) | zzzz[3];
+}
+
+
+static void
+read_quad_stencil(struct softpipe_surface *sps,
+ GLint x, GLint y, GLubyte ssss[QUAD_SIZE])
+{
+ const GLint invY = sps->surface.height - y - 1;
+ const GLuint *src = (const GLuint *) (sps->surface.ptr
+ + (invY * sps->surface.stride + x) * sps->surface.cpp);
+
+ assert(sps->surface.format == PIPE_FORMAT_Z24_S8);
+
+ /* extract high byte */
+ ssss[0] = src[0] >> 24;
+ ssss[1] = src[1] >> 24;
+ ssss[2] = src[-sps->surface.width] >> 24;
+ ssss[3] = src[-sps->surface.width + 1] >> 24;
+}
+
+static void
+write_quad_stencil(struct softpipe_surface *sps,
+ GLint x, GLint y, const GLubyte ssss[QUAD_SIZE])
+{
+ static const GLuint mask = 0x00ffffff;
+ const GLint invY = sps->surface.height - y - 1;
+ GLuint *dst = (GLuint *) (sps->surface.ptr
+ + (invY * sps->surface.stride + x) * sps->surface.cpp);
+
+ assert(sps->surface.format == PIPE_FORMAT_Z24_S8);
+
+ /* write high byte */
+ dst[0] = (dst[0] & mask) | (ssss[0] << 24);
+ dst[1] = (dst[1] & mask) | (ssss[1] << 24);
+ dst -= sps->surface.stride;
+ dst[0] = (dst[0] & mask) | (ssss[2] << 24);
+ dst[1] = (dst[1] & mask) | (ssss[3] << 24);
+}
+
+
+static void *
+map_surface_buffer(struct pipe_buffer *pb, GLuint access_mode)
+{
+ struct softpipe_surface *sps = (struct softpipe_surface *) pb;
+ struct intel_renderbuffer *irb = (struct intel_renderbuffer *) sps->surface.rb;
+ assert(access_mode == PIPE_MAP_READ_WRITE);
+
+ /*LOCK_HARDWARE(intel);*/
+
+ if (irb->region) {
+ GET_CURRENT_CONTEXT(ctx);
+ struct intel_context *intel = intel_context(ctx);
+#if 0
+ intelFinish(&intel->ctx); /* XXX need this? */
+#endif
+ intel_region_map(intel->intelScreen, irb->region);
+ }
+ pb->ptr = irb->region->map;
+
+ sps->surface.stride = irb->region->pitch;
+ sps->surface.cpp = irb->region->cpp;
+ sps->surface.ptr = irb->region->map;
+
+ return pb->ptr;
+}
+
+
+static void
+unmap_surface_buffer(struct pipe_buffer *pb)
+{
+ struct softpipe_surface *sps = (struct softpipe_surface *) pb;
+ struct intel_renderbuffer *irb = (struct intel_renderbuffer *) sps->surface.rb;
+
+ if (irb->region) {
+ GET_CURRENT_CONTEXT(ctx);
+ struct intel_context *intel = intel_context(ctx);
+ intel_region_unmap(intel->intelScreen, irb->region);
+ }
+ pb->ptr = NULL;
+
+ sps->surface.stride = 0;
+ sps->surface.cpp = 0;
+ sps->surface.ptr = NULL;
+
+ /*UNLOCK_HARDWARE(intel);*/
+}
+
+
+struct pipe_surface *
+intel_new_surface(GLuint intFormat)
+{
+ struct softpipe_surface *sps = CALLOC_STRUCT(softpipe_surface);
+ if (!sps)
+ return NULL;
+
+ sps->surface.width = 0; /* set in intel_alloc_renderbuffer_storage() */
+ sps->surface.height = 0;
+
+ if (intFormat == GL_RGBA8) {
+ sps->surface.format = PIPE_FORMAT_U_A8_R8_G8_B8;
+ sps->read_quad_f_swz = read_quad_f_swz;
+ sps->write_quad_f_swz = write_quad_f_swz;
+ }
+ else if (intFormat == GL_RGB5) {
+ sps->surface.format = PIPE_FORMAT_U_R5_G6_B5;
+
+ }
+ else if (intFormat == GL_DEPTH_COMPONENT16) {
+ sps->surface.format = PIPE_FORMAT_U_Z16;
+
+ }
+ else if (intFormat == GL_DEPTH24_STENCIL8_EXT) {
+ sps->surface.format = PIPE_FORMAT_Z24_S8;
+ sps->read_quad_z = read_quad_z24;
+ sps->write_quad_z = write_quad_z24;
+ sps->read_quad_stencil = read_quad_stencil;
+ sps->write_quad_stencil = write_quad_stencil;
+ }
+ else {
+ /* TBD / unknown */
+
+ }
+
+ sps->surface.buffer.map = map_surface_buffer;
+ sps->surface.buffer.unmap = unmap_surface_buffer;
+
+ return &sps->surface;
+}
+
+
+
+struct pipe_surface *
+xmesa_get_stencil_surface(GLcontext *ctx)
+{
+ /* XXX fix */
+ return NULL;
+}
+
+
+