intel/blorp: Add a format parameter to blorp_fast_clear
[mesa.git] / src / intel / blorp / blorp.h
1 /*
2 * Copyright © 2012 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 <stdbool.h>
28
29 #include "isl/isl.h"
30
31 struct brw_context;
32 struct brw_wm_prog_key;
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 struct blorp_batch;
39 struct blorp_params;
40
41 struct blorp_context {
42 void *driver_ctx;
43
44 const struct isl_device *isl_dev;
45
46 const struct brw_compiler *compiler;
47
48 struct {
49 uint32_t tex;
50 uint32_t rb;
51 uint32_t vb;
52 } mocs;
53
54 bool (*lookup_shader)(struct blorp_context *blorp,
55 const void *key, uint32_t key_size,
56 uint32_t *kernel_out, void *prog_data_out);
57 void (*upload_shader)(struct blorp_context *blorp,
58 const void *key, uint32_t key_size,
59 const void *kernel, uint32_t kernel_size,
60 const void *prog_data, uint32_t prog_data_size,
61 uint32_t *kernel_out, void *prog_data_out);
62 void (*exec)(struct blorp_batch *batch, const struct blorp_params *params);
63 };
64
65 void blorp_init(struct blorp_context *blorp, void *driver_ctx,
66 struct isl_device *isl_dev);
67 void blorp_finish(struct blorp_context *blorp);
68
69 struct blorp_batch {
70 struct blorp_context *blorp;
71 void *driver_batch;
72 };
73
74 void blorp_batch_init(struct blorp_context *blorp, struct blorp_batch *batch,
75 void *driver_batch);
76 void blorp_batch_finish(struct blorp_batch *batch);
77
78 struct blorp_address {
79 void *buffer;
80 uint32_t read_domains;
81 uint32_t write_domain;
82 uint32_t offset;
83 };
84
85 struct blorp_surf
86 {
87 const struct isl_surf *surf;
88 struct blorp_address addr;
89
90 const struct isl_surf *aux_surf;
91 struct blorp_address aux_addr;
92 enum isl_aux_usage aux_usage;
93
94 union isl_color_value clear_color;
95 };
96
97 void
98 blorp_blit(struct blorp_batch *batch,
99 const struct blorp_surf *src_surf,
100 unsigned src_level, unsigned src_layer,
101 enum isl_format src_format, int src_swizzle,
102 const struct blorp_surf *dst_surf,
103 unsigned dst_level, unsigned dst_layer,
104 enum isl_format dst_format,
105 float src_x0, float src_y0,
106 float src_x1, float src_y1,
107 float dst_x0, float dst_y0,
108 float dst_x1, float dst_y1,
109 uint32_t filter, bool mirror_x, bool mirror_y);
110
111 void
112 blorp_fast_clear(struct blorp_batch *batch,
113 const struct blorp_surf *surf,
114 uint32_t level, uint32_t layer, enum isl_format format,
115 uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1);
116
117 void
118 blorp_clear(struct blorp_batch *batch,
119 const struct blorp_surf *surf,
120 uint32_t level, uint32_t layer,
121 uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1,
122 enum isl_format format, union isl_color_value clear_color,
123 bool color_write_disable[4]);
124
125 void
126 blorp_ccs_resolve(struct blorp_batch *batch,
127 struct blorp_surf *surf, enum isl_format format);
128
129 /**
130 * For an overview of the HiZ operations, see the following sections of the
131 * Sandy Bridge PRM, Volume 1, Part2:
132 * - 7.5.3.1 Depth Buffer Clear
133 * - 7.5.3.2 Depth Buffer Resolve
134 * - 7.5.3.3 Hierarchical Depth Buffer Resolve
135 *
136 * Of these, two get entered in the resolve map as needing to be done to the
137 * buffer: depth resolve and hiz resolve.
138 */
139 enum blorp_hiz_op {
140 BLORP_HIZ_OP_NONE,
141 BLORP_HIZ_OP_DEPTH_CLEAR,
142 BLORP_HIZ_OP_DEPTH_RESOLVE,
143 BLORP_HIZ_OP_HIZ_RESOLVE,
144 };
145
146 void
147 blorp_gen6_hiz_op(struct blorp_batch *batch,
148 struct blorp_surf *surf, unsigned level, unsigned layer,
149 enum blorp_hiz_op op);
150
151 #ifdef __cplusplus
152 } /* end extern "C" */
153 #endif /* __cplusplus */