Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /**************************************************************************
  2.  *
  3.  * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
  4.  * All Rights Reserved.
  5.  *
  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:
  13.  *
  14.  * The above copyright notice and this permission notice (including the
  15.  * next paragraph) shall be included in all copies or substantial portions
  16.  * of the Software.
  17.  *
  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.
  25.  *
  26.  **************************************************************************/
  27.  
  28. #include "util/u_format.h"
  29. #include "util/u_surface.h"
  30. #include "sp_context.h"
  31. #include "sp_surface.h"
  32. #include "sp_query.h"
  33.  
  34. static void sp_blit(struct pipe_context *pipe,
  35.                     const struct pipe_blit_info *info)
  36. {
  37.    struct softpipe_context *sp = softpipe_context(pipe);
  38.  
  39.    if (info->src.resource->nr_samples > 1 &&
  40.        info->dst.resource->nr_samples <= 1 &&
  41.        !util_format_is_depth_or_stencil(info->src.resource->format) &&
  42.        !util_format_is_pure_integer(info->src.resource->format)) {
  43.       debug_printf("softpipe: color resolve unimplemented\n");
  44.       return;
  45.    }
  46.  
  47.    if (util_try_blit_via_copy_region(pipe, info)) {
  48.       return; /* done */
  49.    }
  50.  
  51.    if (!util_blitter_is_blit_supported(sp->blitter, info)) {
  52.       debug_printf("softpipe: blit unsupported %s -> %s\n",
  53.                    util_format_short_name(info->src.resource->format),
  54.                    util_format_short_name(info->dst.resource->format));
  55.       return;
  56.    }
  57.  
  58.    /* XXX turn off occlusion and streamout queries */
  59.  
  60.    util_blitter_save_vertex_buffer_slot(sp->blitter, sp->vertex_buffer);
  61.    util_blitter_save_vertex_elements(sp->blitter, sp->velems);
  62.    util_blitter_save_vertex_shader(sp->blitter, sp->vs);
  63.    util_blitter_save_geometry_shader(sp->blitter, sp->gs);
  64.    util_blitter_save_so_targets(sp->blitter, sp->num_so_targets,
  65.                      (struct pipe_stream_output_target**)sp->so_targets);
  66.    util_blitter_save_rasterizer(sp->blitter, sp->rasterizer);
  67.    util_blitter_save_viewport(sp->blitter, &sp->viewport);
  68.    util_blitter_save_scissor(sp->blitter, &sp->scissor);
  69.    util_blitter_save_fragment_shader(sp->blitter, sp->fs);
  70.    util_blitter_save_blend(sp->blitter, sp->blend);
  71.    util_blitter_save_depth_stencil_alpha(sp->blitter, sp->depth_stencil);
  72.    util_blitter_save_stencil_ref(sp->blitter, &sp->stencil_ref);
  73.    /*util_blitter_save_sample_mask(sp->blitter, sp->sample_mask);*/
  74.    util_blitter_save_framebuffer(sp->blitter, &sp->framebuffer);
  75.    util_blitter_save_fragment_sampler_states(sp->blitter,
  76.                      sp->num_samplers[PIPE_SHADER_FRAGMENT],
  77.                      (void**)sp->samplers[PIPE_SHADER_FRAGMENT]);
  78.    util_blitter_save_fragment_sampler_views(sp->blitter,
  79.                      sp->num_sampler_views[PIPE_SHADER_FRAGMENT],
  80.                      sp->sampler_views[PIPE_SHADER_FRAGMENT]);
  81.    util_blitter_save_render_condition(sp->blitter, sp->render_cond_query,
  82.                                       sp->render_cond_cond, sp->render_cond_mode);
  83.    util_blitter_blit(sp->blitter, info);
  84. }
  85.  
  86. static void
  87. softpipe_clear_render_target(struct pipe_context *pipe,
  88.                              struct pipe_surface *dst,
  89.                              const union pipe_color_union *color,
  90.                              unsigned dstx, unsigned dsty,
  91.                              unsigned width, unsigned height)
  92. {
  93.    struct softpipe_context *softpipe = softpipe_context(pipe);
  94.  
  95.    if (!softpipe_check_render_cond(softpipe))
  96.       return;
  97.  
  98.    util_clear_render_target(pipe, dst, color,
  99.                             dstx, dsty, width, height);
  100. }
  101.  
  102.  
  103. static void
  104. softpipe_clear_depth_stencil(struct pipe_context *pipe,
  105.                              struct pipe_surface *dst,
  106.                              unsigned clear_flags,
  107.                              double depth,
  108.                              unsigned stencil,
  109.                              unsigned dstx, unsigned dsty,
  110.                              unsigned width, unsigned height)
  111. {
  112.    struct softpipe_context *softpipe = softpipe_context(pipe);
  113.  
  114.    if (!softpipe_check_render_cond(softpipe))
  115.       return;
  116.  
  117.    util_clear_depth_stencil(pipe, dst, clear_flags,
  118.                             depth, stencil,
  119.                             dstx, dsty, width, height);
  120. }
  121.  
  122.  
  123. void
  124. sp_init_surface_functions(struct softpipe_context *sp)
  125. {
  126.    sp->pipe.resource_copy_region = util_resource_copy_region;
  127.    sp->pipe.clear_render_target = softpipe_clear_render_target;
  128.    sp->pipe.clear_depth_stencil = softpipe_clear_depth_stencil;
  129.    sp->pipe.blit = sp_blit;
  130. }
  131.