Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright © 2011 Intel Corporation
  3.  *
  4.  * Permission is hereby granted, free of charge, to any person obtaining a
  5.  * copy of this software and associated documentation files (the "Software"),
  6.  * to deal in the Software without restriction, including without limitation
  7.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8.  * and/or sell copies of the Software, and to permit persons to whom the
  9.  * Software is furnished to do so, subject to the following conditions:
  10.  *
  11.  * The above copyright notice and this permission notice (including the next
  12.  * paragraph) shall be included in all copies or substantial portions of the
  13.  * Software.
  14.  *
  15.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  18.  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19.  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20.  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21.  * IN THE SOFTWARE.
  22.  */
  23.  
  24. #pragma once
  25.  
  26. #include <stdint.h>
  27. #include "glsl/list.h"
  28.  
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32.  
  33. /**
  34.  * For an overview of the HiZ operations, see the following sections of the
  35.  * Sandy Bridge PRM, Volume 1, Part2:
  36.  *   - 7.5.3.1 Depth Buffer Clear
  37.  *   - 7.5.3.2 Depth Buffer Resolve
  38.  *   - 7.5.3.3 Hierarchical Depth Buffer Resolve
  39.  *
  40.  * Of these, two get entered in the resolve map as needing to be done to the
  41.  * buffer: depth resolve and hiz resolve.
  42.  */
  43. enum gen6_hiz_op {
  44.    GEN6_HIZ_OP_DEPTH_CLEAR,
  45.    GEN6_HIZ_OP_DEPTH_RESOLVE,
  46.    GEN6_HIZ_OP_HIZ_RESOLVE,
  47.    GEN6_HIZ_OP_NONE,
  48. };
  49.  
  50. /**
  51.  * \brief Map of miptree slices to needed resolves.
  52.  *
  53.  * The map is implemented as a linear doubly-linked list.
  54.  *
  55.  * In the intel_resolve_map*() functions, the \c head argument is not
  56.  * inspected for its data. It only serves as an anchor for the list.
  57.  *
  58.  * \par Design Discussion
  59.  *
  60.  *     There are two possible ways to record which miptree slices need
  61.  *     resolves. 1) Maintain a flag for every miptree slice in the texture,
  62.  *     likely in intel_mipmap_level::slice, or 2) maintain a list of only
  63.  *     those slices that need a resolve.
  64.  *
  65.  *     Immediately before drawing, a full depth resolve performed on each
  66.  *     enabled depth texture. If design 1 were chosen, then at each draw call
  67.  *     it would be necessary to iterate over each miptree slice of each
  68.  *     enabled depth texture in order to query if each slice needed a resolve.
  69.  *     In the worst case, this would require 2^16 iterations: 16 texture
  70.  *     units, 16 miplevels, and 256 depth layers (assuming maximums for OpenGL
  71.  *     2.1).
  72.  *
  73.  *     By choosing design 2, the number of iterations is exactly the minimum
  74.  *     necessary.
  75.  */
  76. struct intel_resolve_map {
  77.    struct exec_node link;
  78.  
  79.    uint32_t level;
  80.    uint32_t layer;
  81.    enum gen6_hiz_op need;
  82. };
  83.  
  84. void
  85. intel_resolve_map_set(struct exec_list *resolve_map,
  86.                       uint32_t level,
  87.                       uint32_t layer,
  88.                       enum gen6_hiz_op need);
  89.  
  90. struct intel_resolve_map *
  91. intel_resolve_map_get(struct exec_list *resolve_map,
  92.                       uint32_t level,
  93.                       uint32_t layer);
  94.  
  95. void
  96. intel_resolve_map_remove(struct intel_resolve_map *resolve_map);
  97.  
  98. void
  99. intel_resolve_map_clear(struct exec_list *resolve_map);
  100.  
  101. #ifdef __cplusplus
  102. } /* extern "C" */
  103. #endif
  104.  
  105.