From f38d26fd83a2193c6cba9ce72d912f579b25f5fe Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 30 Jul 2007 13:09:53 -0600 Subject: added map/unmap() stubs --- src/mesa/drivers/x11/xm_surface.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/x11/xm_surface.c b/src/mesa/drivers/x11/xm_surface.c index 58081a36a0..9d6db2b5ce 100644 --- a/src/mesa/drivers/x11/xm_surface.c +++ b/src/mesa/drivers/x11/xm_surface.c @@ -69,6 +69,20 @@ xmesa_surface(struct softpipe_surface *sps) } +static void * +map_surface_buffer(struct pipe_buffer *pb, GLuint access_mode) +{ + /* no-op */ +} + + +static void +unmap_surface_buffer(struct pipe_buffer *pb) +{ + /* no-op */ +} + + /** * quad reading/writing * These functions are just wrappers around the existing renderbuffer @@ -199,6 +213,9 @@ create_surface(XMesaContext xmctx, struct xmesa_renderbuffer *xrb) xmsurf->sps.write_quad_ub = write_quad_ub; xmsurf->sps.write_mono_row_ub = write_mono_row_ub; + xmsurf->sps.surface.buffer.map = map_surface_buffer; + xmsurf->sps.surface.buffer.unmap = unmap_surface_buffer; + #if 0 if (xrb->ximage) { xmsurf->sps.surface.ptr = (GLubyte *) xrb->ximage->data; -- cgit v1.2.3 From a548d3cb71116f93d6cd9bc818c57b70ac9d9504 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 30 Jul 2007 13:10:12 -0600 Subject: call st_invalidate_state() --- src/mesa/drivers/dri/i915tex/i915_context.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') 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. -- cgit v1.2.3 From 737f6e7eb1f90133c81cff83444191df84754e77 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 30 Jul 2007 13:10:52 -0600 Subject: disable ProgramStringNotify assertion --- src/mesa/state_tracker/st_cb_program.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index fa9eaf446e..6da2aeb2f2 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -153,7 +153,9 @@ void st_init_cb_program( struct st_context *st ) st->ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; st->ctx->FragmentProgram._UseTexEnvProgram = GL_TRUE; +#if 0 assert(functions->ProgramStringNotify == _tnl_program_string); +#endif functions->BindProgram = st_bind_program; functions->NewProgram = st_new_program; functions->DeleteProgram = st_delete_program; -- cgit v1.2.3 From 1c8905790be301da6d18d2397fd3bbe4a47f987c Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 30 Jul 2007 13:11:09 -0600 Subject: remove old comments --- src/mesa/pipe/softpipe/sp_prim_setup.c | 9 --------- 1 file changed, 9 deletions(-) (limited to 'src') diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index d07bd5381d..7b09d7940e 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -1018,20 +1018,11 @@ static void setup_begin( struct draw_stage *stage ) struct setup_stage *setup = setup_stage(stage); setup->quad.nr_attrs = setup->softpipe->nr_frag_attrs; - - /* - * XXX this is where we might map() the renderbuffers to begin - * s/w rendering. - */ } static void setup_end( struct draw_stage *stage ) { - /* - * XXX this is where we might unmap() the renderbuffers after - * s/w rendering. - */ } -- cgit v1.2.3 From f1569bf0d5fcfd4430e13d6d1bd9c60fb44e9535 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 30 Jul 2007 13:11:27 -0600 Subject: map/unmap surfaces before/after rendering --- src/mesa/pipe/softpipe/sp_context.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src') diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 3bb04a6835..6b44fabfa4 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -32,12 +32,40 @@ #include "main/imports.h" #include "main/macros.h" #include "pipe/draw/draw_context.h" +#include "pipe/p_defines.h" #include "sp_context.h" #include "sp_clear.h" #include "sp_state.h" +#include "sp_surface.h" #include "sp_prim_setup.h" +static void map_surfaces(struct softpipe_context *sp) +{ + GLuint i; + + for (i = 0; i < sp->framebuffer.num_cbufs; i++) { + struct softpipe_surface *sps = softpipe_surface(sp->framebuffer.cbufs[i]); + struct pipe_buffer *buf = &sps->surface.buffer; + buf->map(buf, PIPE_MAP_READ_WRITE); + } + /* XXX depth & stencil bufs */ +} + + +static void unmap_surfaces(struct softpipe_context *sp) +{ + GLuint i; + + for (i = 0; i < sp->framebuffer.num_cbufs; i++) { + struct softpipe_surface *sps = softpipe_surface(sp->framebuffer.cbufs[i]); + struct pipe_buffer *buf = &sps->surface.buffer; + buf->unmap(buf); + } + /* XXX depth & stencil bufs */ +} + + static void softpipe_destroy( struct pipe_context *pipe ) { struct softpipe_context *softpipe = softpipe_context( pipe ); @@ -56,7 +84,10 @@ static void softpipe_draw_vb( struct pipe_context *pipe, if (softpipe->dirty) softpipe_update_derived( softpipe ); + /* XXX move mapping/unmapping to higher/coarser level? */ + map_surfaces(softpipe); draw_vb( softpipe->draw, VB ); + unmap_surfaces(softpipe); } -- cgit v1.2.3 From 3a35ce336458352653329426c550bfce1ffc3f66 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 30 Jul 2007 13:11:52 -0600 Subject: implement surfaces for softpipe rendering --- src/mesa/drivers/dri/i915tex/Makefile | 1 + src/mesa/drivers/dri/i915tex/intel_fbo.h | 18 +++ src/mesa/drivers/dri/i915tex/intel_surface.c | 163 +++++++++++++++++++++++++++ 3 files changed, 182 insertions(+) create mode 100644 src/mesa/drivers/dri/i915tex/intel_surface.c (limited to 'src') 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/intel_fbo.h b/src/mesa/drivers/dri/i915tex/intel_fbo.h index 963f5e706f..1642ce774f 100644 --- a/src/mesa/drivers/dri/i915tex/intel_fbo.h +++ b/src/mesa/drivers/dri/i915tex/intel_fbo.h @@ -29,9 +29,25 @@ #define INTEL_FBO_H +#include "pipe/p_state.h" +#include "pipe/softpipe/sp_surface.h" + + struct intel_context; struct intel_region; + +/** + * Intel "pipe" surface. This is kind of a temporary thing as + * renderbuffers and surfaces should eventually become one. + */ +struct intel_surface +{ + struct softpipe_surface surface; /**< base class */ + struct intel_renderbuffer *rb; /**< ptr back to matching renderbuffer */ +}; + + /** * Intel framebuffer, derived from gl_framebuffer. */ @@ -82,6 +98,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; }; 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..29b640e58e --- /dev/null +++ b/src/mesa/drivers/dri/i915tex/intel_surface.c @@ -0,0 +1,163 @@ +#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 + */ + +extern void +intel_map_unmap_buffers(struct intel_context *intel, GLboolean map); + + + +static void +read_quad_f_swz(struct softpipe_surface *gs, GLint x, GLint y, + GLfloat (*rrrr)[QUAD_SIZE]) +{ + + +} + + +static void +write_quad_f_swz(struct softpipe_surface *sps, GLint x, GLint y, + GLfloat (*rrrr)[QUAD_SIZE]) +{ + struct intel_surface *is = (struct intel_surface *) sps; + struct intel_renderbuffer *irb = is->rb; + const GLfloat *src = (const GLfloat *) rrrr; + GLubyte *dst = (GLubyte *) irb->region->map + + (y * irb->region->pitch + x) * irb->region->cpp; + GLubyte temp[16]; + GLuint i, j; + + for (i = 0; i < 4; i++) { + for (j = 0; j < 4; j++) { + UNCLAMPED_FLOAT_TO_UBYTE(temp[j * 4 + i], src[i * 4 + j]); + } + } + + printf("intel_surface::write_quad\n"); + + memcpy(dst, temp, 8); + memcpy(dst + irb->region->pitch * irb->region->cpp, temp + 8, 8); +} + + + +static void * +map_surface_buffer(struct pipe_buffer *pb, GLuint access_mode) +{ + struct intel_surface *is = (struct intel_surface *) pb; + struct intel_renderbuffer *irb = is->rb; + GET_CURRENT_CONTEXT(ctx); + struct intel_context *intel = intel_context(ctx); + + assert(access_mode == PIPE_MAP_READ_WRITE); + + intelFinish(&intel->ctx); + + /*LOCK_HARDWARE(intel);*/ + + if (irb->region) { + intel_region_map(intel->intelScreen, irb->region); + } + pb->ptr = irb->region->map; + + return pb->ptr; +} + + +static void +unmap_surface_buffer(struct pipe_buffer *pb) +{ + struct intel_surface *is = (struct intel_surface *) pb; + struct intel_renderbuffer *irb = is->rb; + GET_CURRENT_CONTEXT(ctx); + struct intel_context *intel = intel_context(ctx); + + if (irb->region) { + intel_region_unmap(intel->intelScreen, irb->region); + } + pb->ptr = NULL; + + /*UNLOCK_HARDWARE(intel);*/ +} + + +struct pipe_surface * +xmesa_get_color_surface(GLcontext *ctx, GLuint i) +{ + struct intel_context *intel = intel_context(ctx); + struct intel_framebuffer *intel_fb; + struct intel_renderbuffer *intel_rb; + + intel_fb = (struct intel_framebuffer *) ctx->DrawBuffer; + intel_rb = intel_fb->color_rb[1]; + + if (!intel_rb->surface) { + /* create surface and attach to intel_rb */ + struct intel_surface *is; + is = CALLOC_STRUCT(intel_surface); + if (is) { + is->surface.surface.width = intel_rb->Base.Width; + is->surface.surface.height = intel_rb->Base.Height; + + is->surface.read_quad_f_swz = read_quad_f_swz; + is->surface.write_quad_f_swz = write_quad_f_swz; + + is->surface.surface.buffer.map = map_surface_buffer; + is->surface.surface.buffer.unmap = unmap_surface_buffer; + + is->rb = intel_rb; + } + intel_rb->surface = is; + } + else { + /* update surface size */ + struct intel_surface *is = intel_rb->surface; + is->surface.surface.width = intel_rb->Base.Width; + is->surface.surface.height = intel_rb->Base.Height; + /* sanity check */ + assert(is->surface.surface.buffer.map == map_surface_buffer); + } + + return &intel_rb->surface->surface.surface; +} + + +struct pipe_surface * +xmesa_get_z_surface(GLcontext *ctx) +{ + /* XXX fix */ + return NULL; +} + + +struct pipe_surface * +xmesa_get_stencil_surface(GLcontext *ctx) +{ + /* XXX fix */ + return NULL; +} + + + -- cgit v1.2.3