mesa/st: Fix piglit read-front with new drawable invalidation v2
[mesa.git] / src / mesa / state_tracker / st_cb_fbo.c
index 7ffee901cdb8fef9cc16af258a616f066240cdfb..5b9e2037423ef2c7f0432fba74c592c1ba706da4 100644 (file)
@@ -74,11 +74,8 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx,
    enum pipe_format format;
    struct pipe_surface surf_tmpl;
 
-   if (strb->format != PIPE_FORMAT_NONE)
-      format = strb->format;
-   else
-      format = st_choose_renderbuffer_format(screen, internalFormat,
-                                             rb->NumSamples);
+   format = st_choose_renderbuffer_format(screen, internalFormat,
+                                          rb->NumSamples);
 
    if (format == PIPE_FORMAT_NONE) {
       return FALSE;
@@ -90,6 +87,7 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx,
    strb->Base.Format = st_pipe_format_to_mesa_format(format);
    strb->Base._BaseFormat = _mesa_base_fbo_format(ctx, internalFormat);
    strb->Base.DataType = st_format_datatype(format);
+   strb->format = format;
 
    strb->defined = GL_FALSE;  /* undefined contents now */
 
@@ -272,7 +270,8 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw)
       strb->Base.InternalFormat = GL_STENCIL_INDEX8_EXT;
       break;
    case PIPE_FORMAT_R16G16B16A16_SNORM:
-      strb->Base.InternalFormat = GL_RGBA16;
+      /* accum buffer */
+      strb->Base.InternalFormat = GL_RGBA16_SNORM;
       break;
    case PIPE_FORMAT_R8_UNORM:
       strb->Base.InternalFormat = GL_R8;
@@ -353,7 +352,7 @@ st_render_texture(struct gl_context *ctx,
       return;
 
    /* get pointer to texture image we're rendeing to */
-   texImage = att->Texture->Image[att->CubeMapFace][att->TextureLevel];
+   texImage = _mesa_get_attachment_teximage(att);
 
    /* create new renderbuffer which wraps the texture image */
    rb = st_new_renderbuffer(ctx, 0);
@@ -471,8 +470,7 @@ st_validate_attachment(struct gl_context *ctx,
       return GL_FALSE;
 
    format = stObj->pt->format;
-   texFormat =
-      stObj->base.Image[att->CubeMapFace][att->TextureLevel]->TexFormat;
+   texFormat = _mesa_get_attachment_teximage_const(att)->TexFormat;
 
    /* If the encoding is sRGB and sRGB rendering cannot be enabled,
     * check for linear format support instead.