Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Mesa 3-D graphics library
  3.  *
  4.  * Copyright (C) 2013 LunarG, Inc.
  5.  *
  6.  * Permission is hereby granted, free of charge, to any person obtaining a
  7.  * copy of this software and associated documentation files (the "Software"),
  8.  * to deal in the Software without restriction, including without limitation
  9.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10.  * and/or sell copies of the Software, and to permit persons to whom the
  11.  * Software is furnished to do so, subject to the following conditions:
  12.  *
  13.  * The above copyright notice and this permission notice shall be included
  14.  * in all copies or substantial portions of the Software.
  15.  *
  16.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  19.  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20.  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  21.  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  22.  * DEALINGS IN THE SOFTWARE.
  23.  *
  24.  * Authors:
  25.  *    Chia-I Wu <olv@lunarg.com>
  26.  */
  27.  
  28. #ifndef ILO_BLITTER_H
  29. #define ILO_BLITTER_H
  30.  
  31. #include "ilo_common.h"
  32. #include "ilo_state.h"
  33.  
  34. enum ilo_blitter_uses {
  35.    ILO_BLITTER_USE_DSA           = 1 << 0,
  36.    ILO_BLITTER_USE_CC            = 1 << 1,
  37.    ILO_BLITTER_USE_VIEWPORT      = 1 << 2,
  38.    ILO_BLITTER_USE_FB_DEPTH      = 1 << 3,
  39.    ILO_BLITTER_USE_FB_STENCIL    = 1 << 4,
  40. };
  41.  
  42. enum ilo_blitter_rectlist_op {
  43.    ILO_BLITTER_RECTLIST_CLEAR_ZS,
  44.    ILO_BLITTER_RECTLIST_RESOLVE_Z,
  45.    ILO_BLITTER_RECTLIST_RESOLVE_HIZ,
  46. };
  47.  
  48. struct blitter_context;
  49. struct pipe_resource;
  50. struct pipe_surface;
  51. struct ilo_context;
  52.  
  53. struct ilo_blitter {
  54.    struct ilo_context *ilo;
  55.    struct blitter_context *pipe_blitter;
  56.  
  57.    /*
  58.     * A minimal context with the goal to send RECTLISTs down the pipeline.
  59.     */
  60.    enum ilo_blitter_rectlist_op op;
  61.    uint32_t uses;
  62.  
  63.    bool initialized;
  64.  
  65.    float vertices[3][2];
  66.    struct ilo_ve_state ve;
  67.    struct pipe_draw_info draw;
  68.  
  69.    struct ilo_viewport_cso viewport;
  70.    struct ilo_dsa_state dsa;
  71.  
  72.    struct {
  73.       struct pipe_stencil_ref stencil_ref;
  74.       ubyte alpha_ref;
  75.       struct pipe_blend_color blend_color;
  76.    } cc;
  77.  
  78.    uint32_t depth_clear_value;
  79.  
  80.    struct {
  81.       struct ilo_surface_cso dst;
  82.       unsigned width, height;
  83.       unsigned num_samples;
  84.    } fb;
  85. };
  86.  
  87. struct ilo_blitter *
  88. ilo_blitter_create(struct ilo_context *ilo);
  89.  
  90. void
  91. ilo_blitter_destroy(struct ilo_blitter *blitter);
  92.  
  93. bool
  94. ilo_blitter_pipe_blit(struct ilo_blitter *blitter,
  95.                       const struct pipe_blit_info *info);
  96.  
  97. bool
  98. ilo_blitter_pipe_copy_resource(struct ilo_blitter *blitter,
  99.                                struct pipe_resource *dst, unsigned dst_level,
  100.                                unsigned dst_x, unsigned dst_y, unsigned dst_z,
  101.                                struct pipe_resource *src, unsigned src_level,
  102.                                const struct pipe_box *src_box);
  103.  
  104. bool
  105. ilo_blitter_pipe_clear_rt(struct ilo_blitter *blitter,
  106.                           struct pipe_surface *rt,
  107.                           const union pipe_color_union *color,
  108.                           unsigned x, unsigned y,
  109.                           unsigned width, unsigned height);
  110.  
  111. bool
  112. ilo_blitter_pipe_clear_zs(struct ilo_blitter *blitter,
  113.                           struct pipe_surface *zs,
  114.                           unsigned clear_flags,
  115.                           double depth, unsigned stencil,
  116.                           unsigned x, unsigned y,
  117.                           unsigned width, unsigned height);
  118.  
  119. bool
  120. ilo_blitter_pipe_clear_fb(struct ilo_blitter *blitter,
  121.                           unsigned buffers,
  122.                           const union pipe_color_union *color,
  123.                           double depth, unsigned stencil);
  124.  
  125. bool
  126. ilo_blitter_blt_copy_resource(struct ilo_blitter *blitter,
  127.                               struct pipe_resource *dst, unsigned dst_level,
  128.                               unsigned dst_x, unsigned dst_y, unsigned dst_z,
  129.                               struct pipe_resource *src, unsigned src_level,
  130.                               const struct pipe_box *src_box);
  131.  
  132. bool
  133. ilo_blitter_blt_clear_rt(struct ilo_blitter *blitter,
  134.                          struct pipe_surface *rt,
  135.                          const union pipe_color_union *color,
  136.                          unsigned x, unsigned y,
  137.                          unsigned width, unsigned height);
  138.  
  139. bool
  140. ilo_blitter_blt_clear_zs(struct ilo_blitter *blitter,
  141.                          struct pipe_surface *zs,
  142.                          unsigned clear_flags,
  143.                          double depth, unsigned stencil,
  144.                          unsigned x, unsigned y,
  145.                          unsigned width, unsigned height);
  146.  
  147. bool
  148. ilo_blitter_rectlist_clear_zs(struct ilo_blitter *blitter,
  149.                               struct pipe_surface *zs,
  150.                               unsigned clear_flags,
  151.                               double depth, unsigned stencil);
  152.  
  153. void
  154. ilo_blitter_rectlist_resolve_z(struct ilo_blitter *blitter,
  155.                                struct pipe_resource *res,
  156.                                unsigned level, unsigned slice);
  157.  
  158. void
  159. ilo_blitter_rectlist_resolve_hiz(struct ilo_blitter *blitter,
  160.                                  struct pipe_resource *res,
  161.                                  unsigned level, unsigned slice);
  162.  
  163. #endif /* ILO_BLITTER_H */
  164.