Merge commit 'origin/master' into gallium-sampler-view
[mesa.git] / src / mesa / state_tracker / st_cb_fbo.c
index 114a8596adfcfa8ec8478fe5d4fb0feb08640fa3..4ccba1db85db03fb4dd93ee525d24219518c9044 100644 (file)
@@ -104,6 +104,7 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
        */
       pipe_surface_reference( &strb->surface, NULL );
       pipe_texture_reference( &strb->texture, NULL );
+      pipe_sampler_view_reference(&strb->sampler_view, NULL);
 
       /* Setup new texture template.
        */
@@ -163,6 +164,7 @@ st_renderbuffer_delete(struct gl_renderbuffer *rb)
    ASSERT(strb);
    pipe_surface_reference(&strb->surface, NULL);
    pipe_texture_reference(&strb->texture, NULL);
+   pipe_sampler_view_reference(&strb->sampler_view, NULL);
    free(strb->data);
    free(strb);
 }
@@ -369,6 +371,8 @@ st_render_texture(GLcontext *ctx,
 
    pipe_surface_reference(&strb->surface, NULL);
 
+   pipe_sampler_view_reference(&strb->sampler_view, st_get_stobj_sampler_view(stObj));
+
    assert(strb->rtt_level <= strb->texture->last_level);
 
    /* new surface for rendering into the texture */
@@ -663,3 +667,14 @@ void st_init_fbo_functions(struct dd_function_table *functions)
    functions->DrawBuffers = st_DrawBuffers;
    functions->ReadBuffer = st_ReadBuffer;
 }
+
+struct pipe_sampler_view *
+st_renderbuffer_get_sampler_view(struct st_renderbuffer *rb,
+                                 struct pipe_context *pipe)
+{
+   if (!rb->sampler_view) {
+      rb->sampler_view = st_sampler_view_from_texture(pipe, rb->texture);
+   }
+
+   return rb->sampler_view;
+}