return info.size;
}
-static INLINE GLboolean pf_is_depth_stencil( enum pipe_format format )
-{
- return (pf_get_component_bits( format, PIPE_FORMAT_COMP_Z ) +
- pf_get_component_bits( format, PIPE_FORMAT_COMP_S )) != 0;
-}
-
/**
* gl_renderbuffer::AllocStorage()
* This is called to allocate the original drawing surface, and
{
struct pipe_context *pipe = ctx->st->pipe;
struct st_renderbuffer *strb = st_renderbuffer(rb);
- struct pipe_texture template, *texture;
+ struct pipe_texture template;
unsigned surface_usage;
- /* Free the old surface (and texture if we hold the last
- * reference):
+ /* Free the old surface and texture
*/
pipe_surface_reference( &strb->surface, NULL );
+ pipe_texture_reference( &strb->texture, NULL );
+
memset(&template, 0, sizeof(template));
template.target = PIPE_TEXTURE_2D;
template.compressed = 0;
- template.cpp = pf_get_size(template.format);
+ pf_get_block(template.format, &template.block);
template.width[0] = width;
template.height[0] = height;
template.depth[0] = 1;
template.last_level = 0;
+ template.nr_samples = rb->Samples;
if (pf_is_depth_stencil(template.format)) {
template.tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
/* Probably need dedicated flags for surface usage too:
*/
surface_usage = (PIPE_BUFFER_USAGE_GPU_READ |
- PIPE_BUFFER_USAGE_GPU_WRITE |
+ PIPE_BUFFER_USAGE_GPU_WRITE);
+#if 0
PIPE_BUFFER_USAGE_CPU_READ |
PIPE_BUFFER_USAGE_CPU_WRITE);
+#endif
- texture = pipe->screen->texture_create( pipe->screen,
- &template );
+ strb->texture = pipe->screen->texture_create( pipe->screen,
+ &template );
/* Special path for accum buffers.
*
* only for now, the surface pixel format doesn't really matter,
* only that the buffer is large enough.
*/
- if (!texture && template.format == DEFAULT_ACCUM_PIPE_FORMAT)
+ if (!strb->texture && template.format == DEFAULT_ACCUM_PIPE_FORMAT)
{
/* Actually, just setting this usage value should be sufficient
* to tell the driver to go ahead and allocate the buffer, even
surface_usage = (PIPE_BUFFER_USAGE_CPU_READ |
PIPE_BUFFER_USAGE_CPU_WRITE);
- texture = pipe->screen->texture_create( pipe->screen,
- &template );
+ strb->texture = pipe->screen->texture_create( pipe->screen,
+ &template );
}
- if (!texture)
+ if (!strb->texture)
return FALSE;
strb->surface = pipe->screen->get_tex_surface( pipe->screen,
- texture,
+ strb->texture,
0, 0, 0,
surface_usage );
- pipe_texture_reference( &texture, NULL );
-
+ assert(strb->surface->texture);
assert(strb->surface->buffer);
assert(strb->surface->format);
- assert(strb->surface->cpp);
+ assert(strb->surface->block.size);
+ assert(strb->surface->block.width);
+ assert(strb->surface->block.height);
assert(strb->surface->width == width);
assert(strb->surface->height == height);
- assert(strb->surface->pitch);
+ assert(strb->surface->stride);
return strb->surface != NULL;
struct st_renderbuffer *strb = st_renderbuffer(rb);
ASSERT(strb);
pipe_surface_reference(&strb->surface, NULL);
+ pipe_texture_reference(&strb->texture, NULL);
free(strb);
}
* renderbuffer). The window system code determines the format.
*/
struct gl_renderbuffer *
-st_new_renderbuffer_fb(enum pipe_format format)
+st_new_renderbuffer_fb(enum pipe_format format, int samples)
{
struct st_renderbuffer *strb;
_mesa_init_renderbuffer(&strb->Base, 0);
strb->Base.ClassID = 0x4242; /* just a unique value */
+ strb->Base.Samples = samples;
strb->format = format;
switch (format) {
struct gl_framebuffer *fb,
struct gl_renderbuffer_attachment *att)
{
- struct st_context *st = ctx->st;
struct st_renderbuffer *strb;
struct gl_renderbuffer *rb;
- struct pipe_context *pipe = st->pipe;
- struct pipe_screen *screen = pipe->screen;
struct pipe_texture *pt;
+ struct st_texture_object *stObj;
+ const struct gl_texture_image *texImage =
+ att->Texture->Image[att->CubeMapFace][att->TextureLevel];
+
assert(!att->Renderbuffer);
strb = st_renderbuffer(rb);
/* get the texture for the texture object */
+ stObj = st_texture_object(att->Texture);
+
+ /* point renderbuffer at texobject */
+ strb->rtt = stObj;
+ strb->rtt_level = att->TextureLevel;
+ strb->rtt_face = att->CubeMapFace;
+ strb->rtt_slice = att->Zoffset;
+
+ rb->Width = texImage->Width2;
+ rb->Height = texImage->Height2;
+ /*printf("***** render to texture level %d: %d x %d\n", att->TextureLevel, rb->Width, rb->Height);*/
+
pt = st_get_texobj_texture(att->Texture);
- assert(pt);
- assert(pt->width[att->TextureLevel]);
- rb->Width = pt->width[att->TextureLevel];
- rb->Height = pt->height[att->TextureLevel];
+ pipe_texture_reference( &strb->texture, pt );
+
+ pipe_surface_reference(&strb->surface, NULL);
- /* the renderbuffer's surface is inside the texture */
- strb->surface = screen->get_tex_surface(screen, pt,
- att->CubeMapFace,
- att->TextureLevel,
- att->Zoffset,
- PIPE_BUFFER_USAGE_GPU_READ |
- PIPE_BUFFER_USAGE_GPU_WRITE);
- assert(strb->surface);
- assert(screen->is_format_supported(screen, strb->surface->format, PIPE_TEXTURE));
- assert(screen->is_format_supported(screen, strb->surface->format, PIPE_SURFACE));
+ /* the new surface will be created during framebuffer validation */
- init_renderbuffer_bits(strb, pt->format);
+ if (pt) {
+ /*printf("***** pipe texture %d x %d\n", pt->width[0], pt->height[0]);*/
+ init_renderbuffer_bits(strb, pt->format);
+ }
/*
printf("RENDER TO TEXTURE obj=%p pt=%p surf=%p %d x %d\n",
struct pipe_screen *screen = ctx->st->pipe->screen;
struct st_renderbuffer *strb = st_renderbuffer(att->Renderbuffer);
- assert(strb);
+ if (!strb)
+ return;
+
+ st_flush( ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL );
- ctx->st->pipe->flush(ctx->st->pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
+ if (strb->surface)
+ screen->tex_surface_release( screen, &strb->surface );
- screen->tex_surface_release( screen, &strb->surface );
+ strb->rtt = NULL;
/*
printf("FINISH RENDER TO TEXTURE surf=%p\n", strb->surface);