Subversion Repositories Kolibri OS

Rev

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

  1. /*
  2.  * Mesa 3-D graphics library
  3.  *
  4.  * Copyright (C) 2012-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_RESOURCE_H
  29. #define ILO_RESOURCE_H
  30.  
  31. #include "intel_winsys.h"
  32.  
  33. #include "ilo_common.h"
  34.  
  35. struct ilo_screen;
  36.  
  37. struct ilo_buffer {
  38.    struct pipe_resource base;
  39.  
  40.    struct intel_bo *bo;
  41.    unsigned bo_size;
  42.    unsigned bo_flags;
  43. };
  44.  
  45. struct ilo_texture {
  46.    struct pipe_resource base;
  47.  
  48.    bool imported;
  49.    unsigned bo_flags;
  50.  
  51.    enum pipe_format bo_format;
  52.    struct intel_bo *bo;
  53.  
  54.    /*
  55.     * These are the values passed to or returned from winsys for bo
  56.     * allocation.  As such,
  57.     *
  58.     *  - width and height are in blocks,
  59.     *  - cpp is the block size in bytes, and
  60.     *  - stride is the distance in bytes between two block rows.
  61.     */
  62.    int bo_width, bo_height, bo_cpp, bo_stride;
  63.    enum intel_tiling_mode tiling;
  64.  
  65.    bool compressed;
  66.    unsigned block_width;
  67.    unsigned block_height;
  68.  
  69.    /* true if the mip level alignments are stricter */
  70.    bool halign_8, valign_4;
  71.    /* true if space is reserved between layers */
  72.    bool array_spacing_full;
  73.    /* true if samples are interleaved */
  74.    bool interleaved;
  75.  
  76.    /* 2D offsets into a layer/slice/face */
  77.    struct ilo_texture_slice {
  78.       unsigned x;
  79.       unsigned y;
  80.    } *slice_offsets[PIPE_MAX_TEXTURE_LEVELS];
  81.  
  82.    struct ilo_texture *separate_s8;
  83. };
  84.  
  85. static inline struct ilo_buffer *
  86. ilo_buffer(struct pipe_resource *res)
  87. {
  88.    return (struct ilo_buffer *)
  89.       ((res && res->target == PIPE_BUFFER) ? res : NULL);
  90. }
  91.  
  92. static inline struct ilo_texture *
  93. ilo_texture(struct pipe_resource *res)
  94. {
  95.    return (struct ilo_texture *)
  96.       ((res && res->target != PIPE_BUFFER) ? res : NULL);
  97. }
  98.  
  99. void
  100. ilo_init_resource_functions(struct ilo_screen *is);
  101.  
  102. bool
  103. ilo_buffer_alloc_bo(struct ilo_buffer *buf);
  104.  
  105. bool
  106. ilo_texture_alloc_bo(struct ilo_texture *tex);
  107.  
  108. unsigned
  109. ilo_texture_get_slice_offset(const struct ilo_texture *tex,
  110.                              int level, int slice,
  111.                              unsigned *x_offset, unsigned *y_offset);
  112.  
  113. #endif /* ILO_RESOURCE_H */
  114.