summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker/st_cb_fbo.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/state_tracker/st_cb_fbo.c')
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c51
1 files changed, 38 insertions, 13 deletions
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index 00e9d1dccb..84c2474038 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -48,9 +48,9 @@
#include "st_format.h"
#include "st_public.h"
#include "st_texture.h"
+#include "st_manager.h"
#include "util/u_format.h"
-#include "util/u_rect.h"
#include "util/u_inlines.h"
@@ -103,6 +103,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.
*/
@@ -162,6 +163,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);
}
@@ -368,6 +370,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 */
@@ -379,6 +383,8 @@ st_render_texture(GLcontext *ctx,
PIPE_BUFFER_USAGE_GPU_READ |
PIPE_BUFFER_USAGE_GPU_WRITE);
+ strb->format = pt->format;
+
strb->Base.Format = st_pipe_format_to_mesa_format(pt->format);
strb->Base.DataType = st_format_datatype(pt->format);
@@ -511,17 +517,10 @@ copy_back_to_front(struct st_context *st,
(void) st_get_framebuffer_surface(stfb, backIndex, &surf_back);
if (surf_front && surf_back) {
- if (st->pipe->surface_copy) {
- st->pipe->surface_copy(st->pipe,
- surf_front, 0, 0, /* dest */
- surf_back, 0, 0, /* src */
- fb->Width, fb->Height);
- } else {
- util_surface_copy(st->pipe, FALSE,
- surf_front, 0, 0,
- surf_back, 0, 0,
- fb->Width, fb->Height);
- }
+ st->pipe->surface_copy(st->pipe,
+ surf_front, 0, 0, /* dest */
+ surf_back, 0, 0, /* src */
+ fb->Width, fb->Height);
}
}
@@ -612,8 +611,18 @@ check_create_front_buffers(GLcontext *ctx, struct gl_framebuffer *fb)
static void
st_DrawBuffers(GLcontext *ctx, GLsizei count, const GLenum *buffers)
{
+ GLframebuffer *fb = ctx->DrawBuffer;
+ GLuint i;
+
(void) count;
(void) buffers;
+
+ /* add the renderbuffers on demand */
+ for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
+ gl_buffer_index idx = fb->_ColorDrawBufferIndexes[i];
+ st_manager_add_color_renderbuffer(ctx->st, fb, idx);
+ }
+
check_create_front_buffers(ctx, ctx->DrawBuffer);
}
@@ -624,8 +633,13 @@ st_DrawBuffers(GLcontext *ctx, GLsizei count, const GLenum *buffers)
static void
st_ReadBuffer(GLcontext *ctx, GLenum buffer)
{
+ GLframebuffer *fb = ctx->ReadBuffer;
+
(void) buffer;
- check_create_front_buffers(ctx, ctx->ReadBuffer);
+
+ /* add the renderbuffer on demand */
+ st_manager_add_color_renderbuffer(ctx->st, fb, fb->_ColorReadBufferIndex);
+ check_create_front_buffers(ctx, fb);
}
@@ -645,3 +659,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;
+}