mesa: Make core Mesa allocate the texture renderbuffer wrapper.
[mesa.git] / src / mesa / state_tracker / st_cb_fbo.c
index 4619aec0c77d6b36d39131af5923c38cd0092a82..affe6561b156c67ad40bc68749cf74394ed8ca1a 100644 (file)
@@ -390,8 +390,8 @@ st_render_texture(struct gl_context *ctx,
 {
    struct st_context *st = st_context(ctx);
    struct pipe_context *pipe = st->pipe;
-   struct st_renderbuffer *strb;
-   struct gl_renderbuffer *rb;
+   struct gl_renderbuffer *rb = att->Renderbuffer;
+   struct st_renderbuffer *strb = st_renderbuffer(rb);
    struct pipe_resource *pt;
    struct st_texture_object *stObj;
    const struct gl_texture_image *texImage;
@@ -406,24 +406,6 @@ st_render_texture(struct gl_context *ctx,
    /* get pointer to texture image we're rendeing to */
    texImage = _mesa_get_attachment_teximage(att);
 
-   /* create new renderbuffer which wraps the texture image.
-    * Use the texture's name as the renderbuffer's name so that we have
-    * something that's non-zero (to determine vertical orientation) and
-    * possibly helpful for debugging.
-    */
-   rb = st_new_renderbuffer(ctx, att->Texture->Name);
-   if (!rb) {
-      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glFramebufferTexture()");
-      return;
-   }
-
-   _mesa_reference_renderbuffer(&att->Renderbuffer, rb);
-   assert(rb->RefCount == 1);
-   rb->AllocStorage = NULL; /* should not get called */
-   strb = st_renderbuffer(rb);
-
-   assert(strb->Base.RefCount > 0);
-
    /* get the texture for the texture object */
    stObj = st_texture_object(att->Texture);
 
@@ -432,7 +414,7 @@ st_render_texture(struct gl_context *ctx,
    strb->rtt_level = att->TextureLevel;
    strb->rtt_face = att->CubeMapFace;
    strb->rtt_slice = att->Zoffset;
-
+   rb->NumSamples = texImage->NumSamples;
    rb->Width = texImage->Width2;
    rb->Height = texImage->Height2;
    rb->_BaseFormat = texImage->_BaseFormat;