From: Brian Date: Thu, 9 Aug 2007 18:27:44 +0000 (-0600) Subject: checkpoint: no longer using intel_fbo.c X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=64da7515009f3551796c90acc74eb0a2ffdb68a0;p=mesa.git checkpoint: no longer using intel_fbo.c --- diff --git a/src/mesa/drivers/dri/intel_winsys/Makefile b/src/mesa/drivers/dri/intel_winsys/Makefile index 8d3d17e13ee..32c2c3bb24f 100644 --- a/src/mesa/drivers/dri/intel_winsys/Makefile +++ b/src/mesa/drivers/dri/intel_winsys/Makefile @@ -22,10 +22,10 @@ DRIVER_SOURCES = \ intel_ioctl.c \ intel_screen.c \ intel_surface.c \ - intel_fbo.c \ intel_batchpool.c -UNUSED = intel_depthstencil.c +UNUSED = intel_depthstencil.c \ + intel_fbo.c C_SOURCES = \ $(COMMON_SOURCES) \ diff --git a/src/mesa/drivers/dri/intel_winsys/intel_buffers.c b/src/mesa/drivers/dri/intel_winsys/intel_buffers.c index 9266fb62aff..d0139d5b2ad 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_buffers.c +++ b/src/mesa/drivers/dri/intel_winsys/intel_buffers.c @@ -96,6 +96,7 @@ intel_intersect_cliprects(drm_clip_rect_t * dst, /** * Return pointer to current color drawing region, or NULL. */ +#if 0 struct pipe_region * intel_drawbuf_region(struct intel_context *intel) { @@ -120,7 +121,7 @@ intel_readbuf_region(struct intel_context *intel) else return NULL; } - +#endif /** * This will be called whenever the currently bound window is moved/resized. diff --git a/src/mesa/drivers/dri/intel_winsys/intel_context.c b/src/mesa/drivers/dri/intel_winsys/intel_context.c index 9defcc1aaec..0d83d4efd61 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_context.c +++ b/src/mesa/drivers/dri/intel_winsys/intel_context.c @@ -360,6 +360,58 @@ intelCreateContext(const __GLcontextModes * mesaVis, _vbo_CreateContext(ctx); _tnl_CreateContext(ctx); + /* + * Pipe-related setup + */ + if (!getenv("INTEL_HW")) { + intel->pipe = intel_create_softpipe( intel ); + intel->pipe->surface_alloc = intel_new_surface; + intel->pipe->supported_formats = intel_supported_formats; + } + else { + switch (intel->intelScreen->deviceID) { + case PCI_CHIP_I945_G: + case PCI_CHIP_I945_GM: + case PCI_CHIP_I945_GME: + case PCI_CHIP_G33_G: + case PCI_CHIP_Q33_G: + case PCI_CHIP_Q35_G: + case PCI_CHIP_I915_G: + case PCI_CHIP_I915_GM: + intel->pipe = intel_create_i915simple( intel ); + break; + default: + _mesa_printf("Unknown PCIID %x in %s, using software driver\n", + intel->intelScreen->deviceID, __FUNCTION__); + + intel->pipe = intel_create_softpipe( intel ); + break; + } + } + + st_create_context( &intel->ctx, intel->pipe ); + + + /* TODO: Push this down into the pipe driver: + */ + switch (intel->intelScreen->deviceID) { + case PCI_CHIP_I945_G: + case PCI_CHIP_I945_GM: + case PCI_CHIP_I945_GME: + case PCI_CHIP_G33_G: + case PCI_CHIP_Q33_G: + case PCI_CHIP_Q35_G: + intel->pipe->mipmap_tree_layout = i945_miptree_layout; + break; + case PCI_CHIP_I915_G: + case PCI_CHIP_I915_GM: + case PCI_CHIP_I830_M: + case PCI_CHIP_I855_GM: + case PCI_CHIP_I865_G: + intel->pipe->mipmap_tree_layout = i915_miptree_layout; + default: + assert(0); /*FIX*/ + } /* @@ -397,7 +449,9 @@ intelCreateContext(const __GLcontextModes * mesaVis, intel->last_swap_fence = NULL; intel->first_swap_fence = NULL; +#if 00 intel_fbo_init(intel); +#endif if (intel->ctx.Mesa_DXTn) { _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc"); diff --git a/src/mesa/drivers/dri/intel_winsys/intel_fbo.h b/src/mesa/drivers/dri/intel_winsys/intel_fbo.h index 578e1013c2d..2801c7345d0 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_fbo.h +++ b/src/mesa/drivers/dri/intel_winsys/intel_fbo.h @@ -73,19 +73,26 @@ struct intel_framebuffer * not pointers because in some circumstances a deleted renderbuffer could * result in a dangling pointer here. */ +#if 0 struct intel_renderbuffer { struct gl_renderbuffer Base; }; +#endif - +#if 0 extern struct intel_renderbuffer *intel_new_renderbuffer_fb(GLuint intFormat); +#endif extern void intel_fbo_init(struct intel_context *intel); extern struct pipe_surface * -intel_new_surface(GLuint intFormat); +intel_new_surface(struct pipe_context *pipe, GLuint pipeFormat); + + +extern const GLuint * +intel_supported_formats(struct pipe_context *pipe, GLuint *numFormats); #endif /* INTEL_FBO_H */ diff --git a/src/mesa/drivers/dri/intel_winsys/intel_screen.c b/src/mesa/drivers/dri/intel_winsys/intel_screen.c index 74cd714cf34..e5f7b365274 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_screen.c +++ b/src/mesa/drivers/dri/intel_winsys/intel_screen.c @@ -302,34 +302,32 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv, /* fake frontbuffer */ /* XXX allocation should only happen in the unusual case it's actually needed */ - struct intel_renderbuffer *irb - = intel_new_renderbuffer_fb(rgbFormat); - _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_FRONT_LEFT, - &irb->Base); + struct gl_renderbuffer *rb + = st_new_renderbuffer_fb(rgbFormat); + _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_FRONT_LEFT, rb); } if (mesaVis->doubleBufferMode) { - struct intel_renderbuffer *irb - = intel_new_renderbuffer_fb(rgbFormat); - _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT, - &irb->Base); + struct gl_renderbuffer *rb + = st_new_renderbuffer_fb(rgbFormat); + _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT, rb); } if (mesaVis->depthBits == 24 && mesaVis->stencilBits == 8) { /* combined depth/stencil buffer */ - struct intel_renderbuffer *depthStencilRb - = intel_new_renderbuffer_fb(GL_DEPTH24_STENCIL8_EXT); + struct gl_renderbuffer *depthStencilRb + = st_new_renderbuffer_fb(GL_DEPTH24_STENCIL8_EXT); /* note: bind RB to two attachment points */ _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, - &depthStencilRb->Base); + depthStencilRb); _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_STENCIL, - &depthStencilRb->Base); + depthStencilRb); } else if (mesaVis->depthBits == 16) { /* just 16-bit depth buffer, no hw stencil */ - struct intel_renderbuffer *depthRb - = intel_new_renderbuffer_fb(GL_DEPTH_COMPONENT16); - _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, &depthRb->Base); + struct gl_renderbuffer *depthRb + = st_new_renderbuffer_fb(GL_DEPTH_COMPONENT16); + _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, depthRb); } diff --git a/src/mesa/drivers/dri/intel_winsys/intel_surface.c b/src/mesa/drivers/dri/intel_winsys/intel_surface.c index d2e2dabadea..20b6bda83f7 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_surface.c +++ b/src/mesa/drivers/dri/intel_winsys/intel_surface.c @@ -159,8 +159,43 @@ write_quad_stencil(struct softpipe_surface *sps, } + + +static void +a8r8g8b8_get_tile(struct pipe_surface *ps, + GLuint x, GLuint y, GLuint w, GLuint h, GLfloat *p) +{ + const GLuint *src + = ((const GLuint *) (ps->region->map + ps->offset)) + + y * ps->region->pitch + x; + GLuint i, j; +#if 0 + assert(x + w <= ps->width); + assert(y + h <= ps->height); +#else + /* temp hack */ + if (x + w > ps->width) + w = ps->width - x; + if (y + h > ps->height) + h = ps->height -y; +#endif + for (i = 0; i < h; i++) { + for (j = 0; j < w; j++) { + p[0] = UBYTE_TO_FLOAT((src[j] >> 16) & 0xff); + p[1] = UBYTE_TO_FLOAT((src[j] >> 8) & 0xff); + p[2] = UBYTE_TO_FLOAT((src[j] >> 0) & 0xff); + p[3] = UBYTE_TO_FLOAT((src[j] >> 24) & 0xff); + p += 4; + } + src += ps->region->pitch; + } +} + + + + struct pipe_surface * -intel_new_surface(GLuint intFormat) +intel_new_surface(struct pipe_context *pipe, GLuint pipeFormat) { struct softpipe_surface *sps = CALLOC_STRUCT(softpipe_surface); if (!sps) @@ -168,31 +203,42 @@ intel_new_surface(GLuint intFormat) sps->surface.width = 0; /* set in intel_alloc_renderbuffer_storage() */ sps->surface.height = 0; + sps->surface.refcount = 1; + sps->surface.format = pipeFormat; - if (intFormat == GL_RGBA8) { - sps->surface.format = PIPE_FORMAT_U_A8_R8_G8_B8; + switch (pipeFormat) { + case 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_S8_Z24; + sps->surface.get_tile = a8r8g8b8_get_tile; + break; + case PIPE_FORMAT_U_R5_G6_B5: + break; + case PIPE_FORMAT_U_Z16: + break; + case PIPE_FORMAT_S8_Z24: 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 */ - + break; } return &sps->surface; } + + + +const GLuint * +intel_supported_formats(struct pipe_context *pipe, GLuint *numFormats) +{ + static const GLuint formats[] = { + PIPE_FORMAT_U_A8_R8_G8_B8, + PIPE_FORMAT_U_R5_G6_B5, + PIPE_FORMAT_S8_Z24, + }; + + *numFormats = sizeof(formats) / sizeof(formats[0]); + return formats; +} + diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index d0205fd6352..3cd1fbe851a 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -53,7 +53,9 @@ struct st_renderbuffer { struct gl_renderbuffer Base; +#if 0 struct pipe_surface *surface; +#endif }; @@ -93,14 +95,14 @@ pipe_get_format_info(GLuint format) { PIPE_FORMAT_U_R8_G8_B8_A8, /* format */ GL_RGBA, /* base_format */ - 4, 4, 4, 4, 0, 0, /* color bits */ + 8, 8, 8, 8, 0, 0, /* color bits */ 0, 0, /* depth, stencil */ 4 /* size in bytes */ }, { PIPE_FORMAT_U_A8_R8_G8_B8, GL_RGBA, /* base_format */ - 4, 4, 4, 4, 0, 0, /* color bits */ + 8, 8, 8, 8, 0, 0, /* color bits */ 0, 0, /* depth, stencil */ 4 /* size in bytes */ }, @@ -166,29 +168,29 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, cpp = info->size; - if (!strb->surface) { - strb->surface = pipe->surface_alloc(pipe, pipeFormat); - if (!strb->surface) + if (!strb->Base.surface) { + strb->Base.surface = pipe->surface_alloc(pipe, pipeFormat); + if (!strb->Base.surface) return GL_FALSE; } /* free old region */ - if (strb->surface->region) { - pipe->region_release(pipe, &strb->surface->region); + if (strb->Base.surface->region) { + pipe->region_release(pipe, &strb->Base.surface->region); } /* Choose a pitch to match hardware requirements: */ pitch = ((cpp * width + 63) & ~63) / cpp; /* XXX fix: device-specific */ - strb->surface->region = pipe->region_alloc(pipe, cpp, pitch, height); - if (!strb->surface->region) + strb->Base.surface->region = pipe->region_alloc(pipe, cpp, pitch, height); + if (!strb->Base.surface->region) return GL_FALSE; /* out of memory, try s/w buffer? */ - ASSERT(strb->surface->region->buffer); + ASSERT(strb->Base.surface->region->buffer); - strb->Base.Width = strb->surface->width = width; - strb->Base.Height = strb->surface->height = height; + strb->Base.Width = strb->Base.surface->width = width; + strb->Base.Height = strb->Base.surface->height = height; return GL_TRUE; } @@ -204,11 +206,11 @@ st_renderbuffer_delete(struct gl_renderbuffer *rb) struct pipe_context *pipe = ctx->st->pipe; struct st_renderbuffer *strb = st_renderbuffer(rb); ASSERT(strb); - if (strb && strb->surface) { + if (strb && strb->Base.surface) { if (rb->surface->region) { - pipe->region_release(pipe, &strb->surface->region); + pipe->region_release(pipe, &strb->Base.surface->region); } - free(strb->surface); + free(strb->Base.surface); } free(strb); } @@ -257,6 +259,76 @@ st_new_renderbuffer(GLcontext *ctx, GLuint name) return NULL; } + +#if 000 +struct gl_renderbuffer * +st_new_renderbuffer_fb(struct pipe_region *region, GLuint width, GLuint height) +{ + struct st_renderbuffer *strb = CALLOC_STRUCT(st_renderbuffer); + if (!strb) + return; + + _mesa_init_renderbuffer(&strb->Base, name); + strb->Base.Delete = st_renderbuffer_delete; + strb->Base.AllocStorage = st_renderbuffer_alloc_storage; + strb->Base.GetPointer = null_get_pointer; + strb->Base.Width = width; + strb->Base.Heigth = height; + + strb->region = region; + + return &strb->Base; +} + +#else + +struct gl_renderbuffer * +st_new_renderbuffer_fb(GLuint intFormat) +{ + struct st_renderbuffer *irb; + + irb = CALLOC_STRUCT(st_renderbuffer); + if (!irb) { + _mesa_error(NULL, GL_OUT_OF_MEMORY, "creating renderbuffer"); + return NULL; + } + + _mesa_init_renderbuffer(&irb->Base, 0); + irb->Base.ClassID = 0x42; /* XXX temp */ + irb->Base.InternalFormat = intFormat; + + switch (intFormat) { + case GL_RGB5: + case GL_RGBA8: + irb->Base._BaseFormat = GL_RGBA; + break; + case GL_DEPTH_COMPONENT16: + irb->Base._BaseFormat = GL_DEPTH_COMPONENT; + break; + case GL_DEPTH24_STENCIL8_EXT: + irb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT; + break; + default: + _mesa_problem(NULL, + "Unexpected intFormat in st_new_renderbuffer"); + return NULL; + } + + /* st-specific methods */ + irb->Base.Delete = st_renderbuffer_delete; + irb->Base.AllocStorage = st_renderbuffer_alloc_storage; + irb->Base.GetPointer = null_get_pointer; + /* span routines set in alloc_storage function */ + + irb->Base.surface = NULL;/*intel_new_surface(intFormat);*/ + /*irb->Base.surface->rb = irb;*/ + + return &irb->Base; +} +#endif + + + /** * Called via ctx->Driver.BindFramebufferEXT(). */ diff --git a/src/mesa/state_tracker/st_cb_fbo.h b/src/mesa/state_tracker/st_cb_fbo.h index 6142434ec67..7f52ab10d71 100644 --- a/src/mesa/state_tracker/st_cb_fbo.h +++ b/src/mesa/state_tracker/st_cb_fbo.h @@ -30,6 +30,14 @@ #define ST_CB_FBO_H +/* +extern struct gl_renderbuffer * +st_new_renderbuffer_fb(struct pipe_region *region, GLuint width, GLuint height); +*/ +extern struct gl_renderbuffer * +st_new_renderbuffer_fb(GLuint intFormat); + + extern void st_init_fbo_functions(struct dd_function_table *functions); diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 0ea06c692d0..9f7916e40e8 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -31,6 +31,7 @@ #include "st_cb_bufferobjects.h" #include "st_cb_clear.h" #include "st_cb_drawpixels.h" +#include "st_cb_fbo.h" #include "st_cb_texture.h" #include "st_atom.h" #include "st_draw.h" @@ -102,6 +103,7 @@ void st_init_driver_functions(struct dd_function_table *functions) st_init_bufferobject_functions(functions); st_init_clear_functions(functions); st_init_drawpixels_functions(functions); + st_init_fbo_functions(functions); st_init_program_functions(functions); st_init_texture_functions(functions); }