1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
33 #include "main/imports.h"
34 #include "main/image.h"
35 #include "main/macros.h"
36 #include "main/texformat.h"
37 #include "shader/program.h"
38 #include "shader/prog_parameter.h"
39 #include "shader/prog_print.h"
41 #include "st_context.h"
42 #include "st_program.h"
43 #include "st_cb_drawpixels.h"
44 #include "st_cb_blit.h"
45 #include "st_cb_fbo.h"
47 #include "util/u_blit.h"
49 #include "cso_cache/cso_context.h"
53 st_init_blit(struct st_context
*st
)
55 st
->blit
= util_create_blit(st
->pipe
);
60 st_destroy_blit(struct st_context
*st
)
62 util_destroy_blit(st
->blit
);
68 st_BlitFramebuffer(GLcontext
*ctx
,
69 GLint srcX0
, GLint srcY0
, GLint srcX1
, GLint srcY1
,
70 GLint dstX0
, GLint dstY0
, GLint dstX1
, GLint dstY1
,
71 GLbitfield mask
, GLenum filter
)
73 struct st_context
*st
= ctx
->st
;
74 struct pipe_context
*pipe
= st
->pipe
;
76 const uint pFilter
= ((filter
== GL_NEAREST
)
77 ? PIPE_TEX_MIPFILTER_NEAREST
78 : PIPE_TEX_MIPFILTER_LINEAR
);
80 if (mask
& GL_COLOR_BUFFER_BIT
) {
81 struct st_renderbuffer
*srcRb
=
82 st_renderbuffer(ctx
->ReadBuffer
->_ColorReadBuffer
);
83 struct st_renderbuffer
*dstRb
=
84 st_renderbuffer(ctx
->DrawBuffer
->_ColorDrawBuffers
[0][0]);
85 struct pipe_surface
*srcSurf
= srcRb
->surface
;
86 struct pipe_surface
*dstSurf
= dstRb
->surface
;
88 srcY0
= srcRb
->Base
.Height
- srcY0
;
89 srcY1
= srcRb
->Base
.Height
- srcY1
;
91 dstY0
= dstRb
->Base
.Height
- dstY0
;
92 dstY1
= dstRb
->Base
.Height
- dstY1
;
94 util_blit_pixels(st
->blit
,
95 srcSurf
, srcX0
, srcY0
, srcX1
, srcY1
,
96 dstSurf
, dstX0
, dstY0
, dstX1
, dstY1
,
102 /* XXX is this sufficient? */
103 st_invalidate_state(ctx
, _NEW_COLOR
| _NEW_TEXTURE
);
105 /* need to "unset" cso state because we went behind the back of the cso
106 * tracker. Without unset, the _set_ calls would be no-ops.
108 cso_unset_blend(st
->cso_context
);
109 cso_unset_depth_stencil_alpha(st
->cso_context
);
110 cso_unset_rasterizer(st
->cso_context
);
111 cso_set_blend(st
->cso_context
, &st
->state
.blend
);
112 cso_set_depth_stencil_alpha(st
->cso_context
, &st
->state
.depth_stencil
);
113 cso_set_rasterizer(st
->cso_context
, &st
->state
.rasterizer
);
114 pipe
->bind_fs_state(pipe
, st
->fp
->driver_shader
);
115 pipe
->bind_vs_state(pipe
, st
->vp
->driver_shader
);
122 st_init_blit_functions(struct dd_function_table
*functions
)
124 functions
->BlitFramebuffer
= st_BlitFramebuffer
;