#include "main/imports.h"
#include "main/image.h"
#include "main/bufferobj.h"
+#include "main/blit.h"
#include "main/format_pack.h"
#include "main/macros.h"
#include "main/mtypes.h"
GLuint ic = 0;
const GLuint shaderIndex = write_depth * 2 + write_stencil;
- assert(shaderIndex < Elements(st->drawpix.shaders));
+ assert(shaderIndex < ARRAY_SIZE(st->drawpix.shaders));
if (st->drawpix.shaders[shaderIndex]) {
/* already have the proper shader */
/* Choose a pixel format for the temp texture which will hold the
* image to draw.
*/
- pipeFormat = st_choose_matching_format(pipe->screen, PIPE_BIND_SAMPLER_VIEW,
+ pipeFormat = st_choose_matching_format(st, PIPE_BIND_SAMPLER_VIEW,
format, type, unpack->SwapBytes);
- if (pipeFormat != PIPE_FORMAT_NONE) {
- mformat = st_pipe_format_to_mesa_format(pipeFormat);
- baseInternalFormat = _mesa_get_format_base_format(mformat);
- }
- else {
+ if (pipeFormat == PIPE_FORMAT_NONE) {
/* Use the generic approach. */
GLenum intFormat = internal_format(ctx, format, type);
- baseInternalFormat = _mesa_base_tex_format(ctx, intFormat);
pipeFormat = st_choose_format(st, intFormat, format, type,
PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW,
FALSE);
assert(pipeFormat != PIPE_FORMAT_NONE);
- mformat = st_pipe_format_to_mesa_format(pipeFormat);
}
+ mformat = st_pipe_format_to_mesa_format(pipeFormat);
+ baseInternalFormat = _mesa_get_format_base_format(mformat);
+
pixels = _mesa_map_pbo_source(ctx, unpack, pixels);
if (!pixels)
return NULL;
cso_save_rasterizer(cso);
cso_save_viewport(cso);
cso_save_samplers(cso, PIPE_SHADER_FRAGMENT);
- cso_save_sampler_views(cso, PIPE_SHADER_FRAGMENT);
+ cso_save_fragment_sampler_views(cso);
cso_save_fragment_shader(cso);
cso_save_stream_outputs(cso);
cso_save_vertex_shader(cso);
+ cso_save_tessctrl_shader(cso);
+ cso_save_tesseval_shader(cso);
cso_save_geometry_shader(cso);
cso_save_vertex_elements(cso);
cso_save_aux_vertex_buffer_slot(cso);
/* vertex shader state: position + texcoord pass-through */
cso_set_vertex_shader_handle(cso, driver_vp);
- /* geometry shader state: disabled */
+ /* disable other shaders */
+ cso_set_tessctrl_shader_handle(cso, NULL);
+ cso_set_tesseval_shader_handle(cso, NULL);
cso_set_geometry_shader_handle(cso, NULL);
/* texture sampling state: */
vp.scale[0] = 0.5f * w;
vp.scale[1] = -0.5f * h;
vp.scale[2] = 0.5f;
- vp.scale[3] = 1.0f;
vp.translate[0] = 0.5f * w;
vp.translate[1] = 0.5f * h;
vp.translate[2] = 0.5f;
- vp.translate[3] = 0.0f;
cso_set_viewport(cso, &vp);
}
cso_set_vertex_elements(cso, 3, st->velems_util_draw);
- cso_set_stream_outputs(st->cso_context, 0, NULL, 0);
+ cso_set_stream_outputs(st->cso_context, 0, NULL, NULL);
/* texture state: */
cso_set_sampler_views(cso, PIPE_SHADER_FRAGMENT, num_sampler_view, sv);
cso_restore_rasterizer(cso);
cso_restore_viewport(cso);
cso_restore_samplers(cso, PIPE_SHADER_FRAGMENT);
- cso_restore_sampler_views(cso, PIPE_SHADER_FRAGMENT);
+ cso_restore_fragment_sampler_views(cso);
cso_restore_fragment_shader(cso);
cso_restore_vertex_shader(cso);
+ cso_restore_tessctrl_shader(cso);
+ cso_restore_tesseval_shader(cso);
cso_restore_geometry_shader(cso);
cso_restore_vertex_elements(cso);
cso_restore_aux_vertex_buffer_slot(cso);
const GLfloat *color;
struct pipe_context *pipe = st->pipe;
GLboolean write_stencil = GL_FALSE, write_depth = GL_FALSE;
- struct pipe_sampler_view *sv[2];
+ struct pipe_sampler_view *sv[2] = { NULL };
int num_sampler_view = 1;
struct st_fp_variant *fpv;
struct gl_pixelstore_attrib clippedUnpack;
color = NULL;
if (st->pixel_xfer.pixelmap_enabled) {
- sv[1] = st->pixel_xfer.pixelmap_sampler_view;
- num_sampler_view++;
+ pipe_sampler_view_reference(&sv[1],
+ st->pixel_xfer.pixelmap_sampler_view);
+ num_sampler_view++;
}
}
if (write_stencil) {
enum pipe_format stencil_format =
util_format_stencil_only(pt->format);
-
+ /* we should not be doing pixel map/transfer (see above) */
+ assert(num_sampler_view == 1);
sv[1] = st_create_texture_sampler_view_format(st->pipe, pt,
stencil_format);
num_sampler_view++;
}
-/**
- * \return TRUE if two regions overlap, FALSE otherwise
- */
-static boolean
-regions_overlap(int srcX0, int srcY0,
- int srcX1, int srcY1,
- int dstX0, int dstY0,
- int dstX1, int dstY1)
-{
- if (MAX2(srcX0, srcX1) < MIN2(dstX0, dstX1))
- return FALSE; /* src completely left of dst */
-
- if (MAX2(dstX0, dstX1) < MIN2(srcX0, srcX1))
- return FALSE; /* dst completely left of src */
-
- if (MAX2(srcY0, srcY1) < MIN2(dstY0, dstY1))
- return FALSE; /* src completely above dst */
-
- if (MAX2(dstY0, dstY1) < MIN2(srcY0, srcY1))
- return FALSE; /* dst completely above src */
-
- return TRUE; /* some overlap */
-}
-
-
/**
* Try to do a glCopyPixels for simple cases with a blit by calling
* pipe->blit().
!ctx->Stencil.Enabled &&
!ctx->FragmentProgram.Enabled &&
!ctx->VertexProgram.Enabled &&
- !ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT] &&
+ !ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT] &&
ctx->DrawBuffer->_NumColorDrawBuffers == 1 &&
!ctx->Query.CondRenderQuery &&
!ctx->Query.CurrentOcclusionObject) {
}
if (rbRead != rbDraw ||
- !regions_overlap(readX, readY, readX + readW, readY + readH,
- drawX, drawY, drawX + drawW, drawY + drawH)) {
+ !_mesa_regions_overlap(readX, readY, readX + readW, readY + readH,
+ drawX, drawY, drawX + drawW, drawY + drawH)) {
struct pipe_blit_info blit;
memset(&blit, 0, sizeof(blit));
struct st_renderbuffer *rbRead;
void *driver_vp, *driver_fp;
struct pipe_resource *pt;
- struct pipe_sampler_view *sv[2];
+ struct pipe_sampler_view *sv[2] = { NULL };
int num_sampler_view = 1;
GLfloat *color;
enum pipe_format srcFormat;
driver_vp = make_passthrough_vertex_shader(st, GL_FALSE);
if (st->pixel_xfer.pixelmap_enabled) {
- sv[1] = st->pixel_xfer.pixelmap_sampler_view;
+ pipe_sampler_view_reference(&sv[1],
+ st->pixel_xfer.pixelmap_sampler_view);
num_sampler_view++;
}
}
{
GLuint i;
- for (i = 0; i < Elements(st->drawpix.shaders); i++) {
+ for (i = 0; i < ARRAY_SIZE(st->drawpix.shaders); i++) {
if (st->drawpix.shaders[i])
_mesa_reference_fragprog(st->ctx, &st->drawpix.shaders[i], NULL);
}