1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright © 2016 Red Hat.
3bf215546Sopenharmony_ci * Copyright © 2016 Bas Nieuwenhuizen
4bf215546Sopenharmony_ci * SPDX-License-Identifier: MIT
5bf215546Sopenharmony_ci *
6bf215546Sopenharmony_ci * based in part on anv driver which is:
7bf215546Sopenharmony_ci * Copyright © 2015 Intel Corporation
8bf215546Sopenharmony_ci */
9bf215546Sopenharmony_ci
10bf215546Sopenharmony_ci#ifndef TU_LRZ_H
11bf215546Sopenharmony_ci#define TU_LRZ_H
12bf215546Sopenharmony_ci
13bf215546Sopenharmony_ci#include "tu_common.h"
14bf215546Sopenharmony_ci
15bf215546Sopenharmony_cienum tu_lrz_force_disable_mask {
16bf215546Sopenharmony_ci   TU_LRZ_FORCE_DISABLE_LRZ = 1 << 0,
17bf215546Sopenharmony_ci   TU_LRZ_FORCE_DISABLE_WRITE = 1 << 1,
18bf215546Sopenharmony_ci};
19bf215546Sopenharmony_ci
20bf215546Sopenharmony_cienum tu_lrz_direction {
21bf215546Sopenharmony_ci   TU_LRZ_UNKNOWN,
22bf215546Sopenharmony_ci   /* Depth func less/less-than: */
23bf215546Sopenharmony_ci   TU_LRZ_LESS,
24bf215546Sopenharmony_ci   /* Depth func greater/greater-than: */
25bf215546Sopenharmony_ci   TU_LRZ_GREATER,
26bf215546Sopenharmony_ci};
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_cistruct tu_lrz_state
29bf215546Sopenharmony_ci{
30bf215546Sopenharmony_ci   /* Depth/Stencil image currently on use to do LRZ */
31bf215546Sopenharmony_ci   const struct tu_image_view *image_view;
32bf215546Sopenharmony_ci   VkClearValue depth_clear_value;
33bf215546Sopenharmony_ci   /* If LRZ is in invalid state we cannot use it until depth is cleared */
34bf215546Sopenharmony_ci   bool valid : 1;
35bf215546Sopenharmony_ci   /* Allows to temporary disable LRZ */
36bf215546Sopenharmony_ci   bool enabled : 1;
37bf215546Sopenharmony_ci   bool fast_clear : 1;
38bf215546Sopenharmony_ci   bool gpu_dir_tracking : 1;
39bf215546Sopenharmony_ci   /* Continue using old LRZ state (LOAD_OP_LOAD of depth) */
40bf215546Sopenharmony_ci   bool reuse_previous_state : 1;
41bf215546Sopenharmony_ci   enum tu_lrz_direction prev_direction;
42bf215546Sopenharmony_ci};
43bf215546Sopenharmony_ci
44bf215546Sopenharmony_civoid
45bf215546Sopenharmony_citu6_emit_lrz(struct tu_cmd_buffer *cmd, struct tu_cs *cs);
46bf215546Sopenharmony_ci
47bf215546Sopenharmony_civoid
48bf215546Sopenharmony_citu_disable_lrz(struct tu_cmd_buffer *cmd, struct tu_cs *cs,
49bf215546Sopenharmony_ci               struct tu_image *image);
50bf215546Sopenharmony_ci
51bf215546Sopenharmony_civoid
52bf215546Sopenharmony_citu_lrz_clear_depth_image(struct tu_cmd_buffer *cmd,
53bf215546Sopenharmony_ci                         struct tu_image *image,
54bf215546Sopenharmony_ci                         const VkClearDepthStencilValue *pDepthStencil,
55bf215546Sopenharmony_ci                         uint32_t rangeCount,
56bf215546Sopenharmony_ci                         const VkImageSubresourceRange *pRanges);
57bf215546Sopenharmony_ci
58bf215546Sopenharmony_civoid
59bf215546Sopenharmony_citu_lrz_begin_renderpass(struct tu_cmd_buffer *cmd,
60bf215546Sopenharmony_ci                        const VkClearValue *clear_values);
61bf215546Sopenharmony_ci
62bf215546Sopenharmony_civoid
63bf215546Sopenharmony_citu_lrz_begin_resumed_renderpass(struct tu_cmd_buffer *cmd,
64bf215546Sopenharmony_ci                                const VkClearValue *clear_values);
65bf215546Sopenharmony_ci
66bf215546Sopenharmony_civoid
67bf215546Sopenharmony_citu_lrz_begin_secondary_cmdbuf(struct tu_cmd_buffer *cmd);
68bf215546Sopenharmony_ci
69bf215546Sopenharmony_civoid
70bf215546Sopenharmony_citu_lrz_tiling_begin(struct tu_cmd_buffer *cmd, struct tu_cs *cs);
71bf215546Sopenharmony_ci
72bf215546Sopenharmony_civoid
73bf215546Sopenharmony_citu_lrz_tiling_end(struct tu_cmd_buffer *cmd, struct tu_cs *cs);
74bf215546Sopenharmony_ci
75bf215546Sopenharmony_civoid
76bf215546Sopenharmony_citu_lrz_sysmem_begin(struct tu_cmd_buffer *cmd, struct tu_cs *cs);
77bf215546Sopenharmony_ci
78bf215546Sopenharmony_civoid
79bf215546Sopenharmony_citu_lrz_sysmem_end(struct tu_cmd_buffer *cmd, struct tu_cs *cs);
80bf215546Sopenharmony_ci
81bf215546Sopenharmony_civoid
82bf215546Sopenharmony_citu_lrz_disable_during_renderpass(struct tu_cmd_buffer *cmd);
83bf215546Sopenharmony_ci
84bf215546Sopenharmony_ci#endif /* TU_LRZ_H */
85