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) \
/**
* Return pointer to current color drawing region, or NULL.
*/
+#if 0
struct pipe_region *
intel_drawbuf_region(struct intel_context *intel)
{
else
return NULL;
}
-
+#endif
/**
* This will be called whenever the currently bound window is moved/resized.
_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*/
+ }
/*
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");
* 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 */
/* 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);
}
}
+
+
+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)
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;
+}
+
struct st_renderbuffer
{
struct gl_renderbuffer Base;
+#if 0
struct pipe_surface *surface;
+#endif
};
{
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 */
},
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;
}
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);
}
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().
*/
#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);
#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"
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);
}