Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2015 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 | #include "anv_meta.h" |
| 25 | #include "anv_meta_clear.h" |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 26 | #include "anv_private.h" |
Jason Ekstrand | a33fcc0 | 2015-12-29 13:47:37 -0800 | [diff] [blame] | 27 | #include "glsl/nir/nir_builder.h" |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 28 | |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 29 | /** Vertex attributes for color clears. */ |
| 30 | struct color_clear_vattrs { |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 31 | struct anv_vue_header vue_header; |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 32 | float position[2]; /**< 3DPRIM_RECTLIST */ |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 33 | VkClearColorValue color; |
| 34 | }; |
| 35 | |
Chad Versace | 16119ad | 2015-11-04 17:00:01 -0800 | [diff] [blame] | 36 | /** Vertex attributes for depthstencil clears. */ |
| 37 | struct depthstencil_clear_vattrs { |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 38 | struct anv_vue_header vue_header; |
| 39 | float position[2]; /*<< 3DPRIM_RECTLIST */ |
| 40 | }; |
| 41 | |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 42 | static void |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 43 | meta_clear_begin(struct anv_meta_saved_state *saved_state, |
| 44 | struct anv_cmd_buffer *cmd_buffer) |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 45 | { |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 46 | anv_meta_save(saved_state, cmd_buffer, |
| 47 | (1 << VK_DYNAMIC_STATE_VIEWPORT) | |
Chad Versace | 16119ad | 2015-11-04 17:00:01 -0800 | [diff] [blame] | 48 | (1 << VK_DYNAMIC_STATE_SCISSOR) | |
| 49 | (1 << VK_DYNAMIC_STATE_STENCIL_REFERENCE)); |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 50 | |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 51 | cmd_buffer->state.dynamic.viewport.count = 0; |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 52 | cmd_buffer->state.dynamic.scissor.count = 0; |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 53 | } |
| 54 | |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 55 | static void |
| 56 | meta_clear_end(struct anv_meta_saved_state *saved_state, |
| 57 | struct anv_cmd_buffer *cmd_buffer) |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 58 | { |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 59 | anv_meta_restore(saved_state, cmd_buffer); |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 60 | } |
| 61 | |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 62 | static void |
| 63 | build_color_shaders(struct nir_shader **out_vs, |
Chad Versace | 0679bef | 2016-01-13 16:29:45 -0800 | [diff] [blame] | 64 | struct nir_shader **out_fs, |
| 65 | uint32_t frag_output) |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 66 | { |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 67 | nir_builder vs_b; |
| 68 | nir_builder fs_b; |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 69 | |
Jason Ekstrand | a33fcc0 | 2015-12-29 13:47:37 -0800 | [diff] [blame] | 70 | nir_builder_init_simple_shader(&vs_b, NULL, MESA_SHADER_VERTEX, NULL); |
| 71 | nir_builder_init_simple_shader(&fs_b, NULL, MESA_SHADER_FRAGMENT, NULL); |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 72 | |
Chad Versace | 13610c0 | 2016-01-13 18:09:01 -0800 | [diff] [blame] | 73 | vs_b.shader->info.name = ralloc_strdup(vs_b.shader, "meta_clear_color_vs"); |
| 74 | fs_b.shader->info.name = ralloc_strdup(fs_b.shader, "meta_clear_color_fs"); |
| 75 | |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 76 | const struct glsl_type *position_type = glsl_vec4_type(); |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 77 | const struct glsl_type *color_type = glsl_vec4_type(); |
| 78 | |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 79 | nir_variable *vs_in_pos = |
| 80 | nir_variable_create(vs_b.shader, nir_var_shader_in, position_type, |
| 81 | "a_position"); |
| 82 | vs_in_pos->data.location = VERT_ATTRIB_GENERIC0; |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 83 | |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 84 | nir_variable *vs_out_pos = |
| 85 | nir_variable_create(vs_b.shader, nir_var_shader_out, position_type, |
| 86 | "gl_Position"); |
| 87 | vs_out_pos->data.location = VARYING_SLOT_POS; |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 88 | |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 89 | nir_variable *vs_in_color = |
| 90 | nir_variable_create(vs_b.shader, nir_var_shader_in, color_type, |
| 91 | "a_color"); |
| 92 | vs_in_color->data.location = VERT_ATTRIB_GENERIC1; |
| 93 | |
| 94 | nir_variable *vs_out_color = |
| 95 | nir_variable_create(vs_b.shader, nir_var_shader_out, color_type, |
| 96 | "v_color"); |
| 97 | vs_out_color->data.location = VARYING_SLOT_VAR0; |
| 98 | vs_out_color->data.interpolation = INTERP_QUALIFIER_FLAT; |
| 99 | |
| 100 | nir_variable *fs_in_color = |
| 101 | nir_variable_create(fs_b.shader, nir_var_shader_in, color_type, |
| 102 | "v_color"); |
| 103 | fs_in_color->data.location = vs_out_color->data.location; |
| 104 | fs_in_color->data.interpolation = vs_out_color->data.interpolation; |
| 105 | |
| 106 | nir_variable *fs_out_color = |
| 107 | nir_variable_create(fs_b.shader, nir_var_shader_out, color_type, |
| 108 | "f_color"); |
Chad Versace | 0679bef | 2016-01-13 16:29:45 -0800 | [diff] [blame] | 109 | fs_out_color->data.location = FRAG_RESULT_DATA0 + frag_output; |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 110 | |
| 111 | nir_copy_var(&vs_b, vs_out_pos, vs_in_pos); |
| 112 | nir_copy_var(&vs_b, vs_out_color, vs_in_color); |
| 113 | nir_copy_var(&fs_b, fs_out_color, fs_in_color); |
| 114 | |
| 115 | *out_vs = vs_b.shader; |
| 116 | *out_fs = fs_b.shader; |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 117 | } |
| 118 | |
Kristian Høgsberg Kristensen | 5526c17 | 2016-01-03 22:43:47 -0800 | [diff] [blame] | 119 | static VkResult |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 120 | create_pipeline(struct anv_device *device, |
| 121 | struct nir_shader *vs_nir, |
| 122 | struct nir_shader *fs_nir, |
| 123 | const VkPipelineVertexInputStateCreateInfo *vi_state, |
| 124 | const VkPipelineDepthStencilStateCreateInfo *ds_state, |
Jason Ekstrand | fcfb404 | 2015-12-02 03:28:27 -0800 | [diff] [blame] | 125 | const VkPipelineColorBlendStateCreateInfo *cb_state, |
Kristian Høgsberg Kristensen | 5526c17 | 2016-01-03 22:43:47 -0800 | [diff] [blame] | 126 | const VkAllocationCallbacks *alloc, |
Chad Versace | 0679bef | 2016-01-13 16:29:45 -0800 | [diff] [blame] | 127 | bool use_repclear, |
Kristian Høgsberg Kristensen | 5526c17 | 2016-01-03 22:43:47 -0800 | [diff] [blame] | 128 | struct anv_pipeline **pipeline) |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 129 | { |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 130 | VkDevice device_h = anv_device_to_handle(device); |
Kristian Høgsberg Kristensen | 5526c17 | 2016-01-03 22:43:47 -0800 | [diff] [blame] | 131 | VkResult result; |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 132 | |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 133 | struct anv_shader_module vs_m = { .nir = vs_nir }; |
| 134 | struct anv_shader_module fs_m = { .nir = fs_nir }; |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 135 | |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 136 | VkPipeline pipeline_h; |
Kristian Høgsberg Kristensen | 5526c17 | 2016-01-03 22:43:47 -0800 | [diff] [blame] | 137 | result = anv_graphics_pipeline_create(device_h, |
Kristian Høgsberg Kristensen | 30521fb | 2016-01-05 12:00:54 -0800 | [diff] [blame] | 138 | VK_NULL_HANDLE, |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 139 | &(VkGraphicsPipelineCreateInfo) { |
| 140 | .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 141 | .stageCount = 2, |
| 142 | .pStages = (VkPipelineShaderStageCreateInfo[]) { |
| 143 | { |
| 144 | .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, |
Jason Ekstrand | a5f19f6 | 2015-12-02 16:08:13 -0800 | [diff] [blame] | 145 | .stage = VK_SHADER_STAGE_VERTEX_BIT, |
Jason Ekstrand | e10dc00 | 2015-12-02 14:35:07 -0800 | [diff] [blame] | 146 | .module = anv_shader_module_to_handle(&vs_m), |
| 147 | .pName = "main", |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 148 | }, |
| 149 | { |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 150 | .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, |
Jason Ekstrand | a5f19f6 | 2015-12-02 16:08:13 -0800 | [diff] [blame] | 151 | .stage = VK_SHADER_STAGE_FRAGMENT_BIT, |
Jason Ekstrand | e10dc00 | 2015-12-02 14:35:07 -0800 | [diff] [blame] | 152 | .module = anv_shader_module_to_handle(&fs_m), |
| 153 | .pName = "main", |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 154 | }, |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 155 | }, |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 156 | .pVertexInputState = vi_state, |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 157 | .pInputAssemblyState = &(VkPipelineInputAssemblyStateCreateInfo) { |
| 158 | .sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 159 | .topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, |
| 160 | .primitiveRestartEnable = false, |
| 161 | }, |
| 162 | .pViewportState = &(VkPipelineViewportStateCreateInfo) { |
| 163 | .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, |
| 164 | .viewportCount = 1, |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 165 | .pViewports = NULL, /* dynamic */ |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 166 | .scissorCount = 1, |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 167 | .pScissors = NULL, /* dynamic */ |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 168 | }, |
Jason Ekstrand | 7f22840 | 2015-11-30 18:05:00 -0800 | [diff] [blame] | 169 | .pRasterizationState = &(VkPipelineRasterizationStateCreateInfo) { |
| 170 | .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 171 | .rasterizerDiscardEnable = false, |
Jason Ekstrand | 9b1cb8f | 2015-11-30 13:28:09 -0800 | [diff] [blame] | 172 | .polygonMode = VK_POLYGON_MODE_FILL, |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 173 | .cullMode = VK_CULL_MODE_NONE, |
Jason Ekstrand | 9b1cb8f | 2015-11-30 13:28:09 -0800 | [diff] [blame] | 174 | .frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE, |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 175 | .depthBiasEnable = false, |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 176 | }, |
| 177 | .pMultisampleState = &(VkPipelineMultisampleStateCreateInfo) { |
| 178 | .sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, |
Jason Ekstrand | 7f22840 | 2015-11-30 18:05:00 -0800 | [diff] [blame] | 179 | .rasterizationSamples = 1, /* FINISHME: Multisampling */ |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 180 | .sampleShadingEnable = false, |
| 181 | .pSampleMask = (VkSampleMask[]) { UINT32_MAX }, |
Jason Ekstrand | 9fa6e32 | 2015-11-30 17:20:49 -0800 | [diff] [blame] | 182 | .alphaToCoverageEnable = false, |
| 183 | .alphaToOneEnable = false, |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 184 | }, |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 185 | .pDepthStencilState = ds_state, |
| 186 | .pColorBlendState = cb_state, |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 187 | .pDynamicState = &(VkPipelineDynamicStateCreateInfo) { |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 188 | /* The meta clear pipeline declares all state as dynamic. |
| 189 | * As a consequence, vkCmdBindPipeline writes no dynamic state |
| 190 | * to the cmd buffer. Therefore, at the end of the meta clear, |
| 191 | * we need only restore dynamic state was vkCmdSet. |
| 192 | */ |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 193 | .sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO, |
| 194 | .dynamicStateCount = 9, |
| 195 | .pDynamicStates = (VkDynamicState[]) { |
| 196 | VK_DYNAMIC_STATE_VIEWPORT, |
| 197 | VK_DYNAMIC_STATE_SCISSOR, |
| 198 | VK_DYNAMIC_STATE_LINE_WIDTH, |
| 199 | VK_DYNAMIC_STATE_DEPTH_BIAS, |
| 200 | VK_DYNAMIC_STATE_BLEND_CONSTANTS, |
| 201 | VK_DYNAMIC_STATE_DEPTH_BOUNDS, |
| 202 | VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK, |
| 203 | VK_DYNAMIC_STATE_STENCIL_WRITE_MASK, |
| 204 | VK_DYNAMIC_STATE_STENCIL_REFERENCE, |
| 205 | }, |
| 206 | }, |
| 207 | .flags = 0, |
| 208 | .renderPass = anv_render_pass_to_handle(&anv_meta_dummy_renderpass), |
| 209 | .subpass = 0, |
| 210 | }, |
| 211 | &(struct anv_graphics_pipeline_create_info) { |
Chad Versace | 2997b0d | 2016-01-13 18:24:18 -0800 | [diff] [blame] | 212 | .color_attachment_count = MAX_RTS, |
Chad Versace | 0679bef | 2016-01-13 16:29:45 -0800 | [diff] [blame] | 213 | .use_repclear = use_repclear, |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 214 | .disable_viewport = true, |
| 215 | .disable_vs = true, |
| 216 | .use_rectlist = true |
| 217 | }, |
Jason Ekstrand | fcfb404 | 2015-12-02 03:28:27 -0800 | [diff] [blame] | 218 | alloc, |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 219 | &pipeline_h); |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 220 | |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 221 | ralloc_free(vs_nir); |
| 222 | ralloc_free(fs_nir); |
| 223 | |
Kristian Høgsberg Kristensen | 5526c17 | 2016-01-03 22:43:47 -0800 | [diff] [blame] | 224 | *pipeline = anv_pipeline_from_handle(pipeline_h); |
| 225 | |
| 226 | return result; |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 227 | } |
| 228 | |
Kristian Høgsberg Kristensen | 5526c17 | 2016-01-03 22:43:47 -0800 | [diff] [blame] | 229 | static VkResult |
Chad Versace | 0679bef | 2016-01-13 16:29:45 -0800 | [diff] [blame] | 230 | create_color_pipeline(struct anv_device *device, uint32_t frag_output, |
| 231 | struct anv_pipeline **pipeline) |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 232 | { |
| 233 | struct nir_shader *vs_nir; |
| 234 | struct nir_shader *fs_nir; |
Chad Versace | 0679bef | 2016-01-13 16:29:45 -0800 | [diff] [blame] | 235 | build_color_shaders(&vs_nir, &fs_nir, frag_output); |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 236 | |
| 237 | const VkPipelineVertexInputStateCreateInfo vi_state = { |
| 238 | .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, |
Jason Ekstrand | e673d64 | 2015-11-30 17:00:30 -0800 | [diff] [blame] | 239 | .vertexBindingDescriptionCount = 1, |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 240 | .pVertexBindingDescriptions = (VkVertexInputBindingDescription[]) { |
| 241 | { |
| 242 | .binding = 0, |
Jason Ekstrand | e673d64 | 2015-11-30 17:00:30 -0800 | [diff] [blame] | 243 | .stride = sizeof(struct color_clear_vattrs), |
Jason Ekstrand | 9b1cb8f | 2015-11-30 13:28:09 -0800 | [diff] [blame] | 244 | .inputRate = VK_VERTEX_INPUT_RATE_VERTEX |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 245 | }, |
| 246 | }, |
Jason Ekstrand | e673d64 | 2015-11-30 17:00:30 -0800 | [diff] [blame] | 247 | .vertexAttributeDescriptionCount = 3, |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 248 | .pVertexAttributeDescriptions = (VkVertexInputAttributeDescription[]) { |
| 249 | { |
| 250 | /* VUE Header */ |
| 251 | .location = 0, |
| 252 | .binding = 0, |
| 253 | .format = VK_FORMAT_R32G32B32A32_UINT, |
Jason Ekstrand | e673d64 | 2015-11-30 17:00:30 -0800 | [diff] [blame] | 254 | .offset = offsetof(struct color_clear_vattrs, vue_header), |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 255 | }, |
| 256 | { |
| 257 | /* Position */ |
| 258 | .location = 1, |
| 259 | .binding = 0, |
| 260 | .format = VK_FORMAT_R32G32_SFLOAT, |
Jason Ekstrand | e673d64 | 2015-11-30 17:00:30 -0800 | [diff] [blame] | 261 | .offset = offsetof(struct color_clear_vattrs, position), |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 262 | }, |
| 263 | { |
| 264 | /* Color */ |
| 265 | .location = 2, |
| 266 | .binding = 0, |
| 267 | .format = VK_FORMAT_R32G32B32A32_SFLOAT, |
Jason Ekstrand | e673d64 | 2015-11-30 17:00:30 -0800 | [diff] [blame] | 268 | .offset = offsetof(struct color_clear_vattrs, color), |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 269 | }, |
| 270 | }, |
| 271 | }; |
| 272 | |
| 273 | const VkPipelineDepthStencilStateCreateInfo ds_state = { |
| 274 | .sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, |
| 275 | .depthTestEnable = false, |
| 276 | .depthWriteEnable = false, |
| 277 | .depthBoundsTestEnable = false, |
| 278 | .stencilTestEnable = false, |
| 279 | }; |
| 280 | |
| 281 | const VkPipelineColorBlendStateCreateInfo cb_state = { |
| 282 | .sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 283 | .logicOpEnable = false, |
| 284 | .attachmentCount = 1, |
| 285 | .pAttachments = (VkPipelineColorBlendAttachmentState []) { |
| 286 | { |
| 287 | .blendEnable = false, |
Jason Ekstrand | 4cf0b57 | 2015-11-30 18:12:55 -0800 | [diff] [blame] | 288 | .colorWriteMask = VK_COLOR_COMPONENT_A_BIT | |
| 289 | VK_COLOR_COMPONENT_R_BIT | |
| 290 | VK_COLOR_COMPONENT_G_BIT | |
| 291 | VK_COLOR_COMPONENT_B_BIT, |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 292 | }, |
| 293 | }, |
| 294 | }; |
| 295 | |
Chad Versace | 0679bef | 2016-01-13 16:29:45 -0800 | [diff] [blame] | 296 | /* Disable repclear because we do not want the compiler to replace the |
| 297 | * shader. We need the shader to write to the specified color attachment, |
| 298 | * but the repclear shader writes to all color attachments. |
| 299 | */ |
Kristian Høgsberg Kristensen | 5526c17 | 2016-01-03 22:43:47 -0800 | [diff] [blame] | 300 | return |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 301 | create_pipeline(device, vs_nir, fs_nir, &vi_state, &ds_state, |
Chad Versace | 0679bef | 2016-01-13 16:29:45 -0800 | [diff] [blame] | 302 | &cb_state, NULL, /*use_repclear*/ false, |
| 303 | pipeline); |
| 304 | } |
| 305 | |
| 306 | static VkResult |
| 307 | init_color_pipelines(struct anv_device *device) |
| 308 | { |
| 309 | VkResult result; |
| 310 | struct anv_pipeline **pipelines = device->meta_state.clear.color_pipelines; |
| 311 | uint32_t n = ARRAY_SIZE(device->meta_state.clear.color_pipelines); |
| 312 | |
| 313 | zero(device->meta_state.clear.color_pipelines); |
| 314 | |
| 315 | for (uint32_t i = 0; i < n; ++i) { |
| 316 | result = create_color_pipeline(device, i, &pipelines[i]); |
| 317 | if (result < 0) |
| 318 | goto fail; |
| 319 | } |
| 320 | |
| 321 | return VK_SUCCESS; |
| 322 | |
| 323 | fail: |
| 324 | for (uint32_t i = 0; i < n; ++i) { |
| 325 | if (pipelines[i] == NULL) |
| 326 | break; |
| 327 | |
| 328 | anv_DestroyPipeline(anv_device_to_handle(device), |
| 329 | anv_pipeline_to_handle(pipelines[i]), |
| 330 | NULL); |
| 331 | } |
| 332 | |
| 333 | return result; |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | static void |
Chad Versace | f2700d6 | 2016-01-13 14:09:36 -0800 | [diff] [blame] | 337 | emit_color_clear(struct anv_cmd_buffer *cmd_buffer, |
Chad Versace | deb8dd8 | 2016-01-13 14:47:51 -0800 | [diff] [blame^] | 338 | const VkClearAttachment *clear_att) |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 339 | { |
| 340 | struct anv_device *device = cmd_buffer->device; |
Chad Versace | deb8dd8 | 2016-01-13 14:47:51 -0800 | [diff] [blame^] | 341 | const struct anv_subpass *subpass = cmd_buffer->state.subpass; |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 342 | const struct anv_framebuffer *fb = cmd_buffer->state.framebuffer; |
Chad Versace | deb8dd8 | 2016-01-13 14:47:51 -0800 | [diff] [blame^] | 343 | VkClearColorValue clear_value = clear_att->clearValue.color; |
| 344 | struct anv_pipeline *pipeline = |
| 345 | device->meta_state.clear.color_pipelines[clear_att->colorAttachment]; |
| 346 | |
| 347 | VkCommandBuffer cmd_buffer_h = anv_cmd_buffer_to_handle(cmd_buffer); |
Chad Versace | 0679bef | 2016-01-13 16:29:45 -0800 | [diff] [blame] | 348 | VkPipeline pipeline_h = anv_pipeline_to_handle(pipeline); |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 349 | |
Chad Versace | deb8dd8 | 2016-01-13 14:47:51 -0800 | [diff] [blame^] | 350 | assert(clear_att->aspectMask == VK_IMAGE_ASPECT_COLOR_BIT); |
| 351 | assert(clear_att->colorAttachment < subpass->color_count); |
| 352 | |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 353 | const struct color_clear_vattrs vertex_data[3] = { |
| 354 | { |
| 355 | .vue_header = { 0 }, |
| 356 | .position = { 0.0, 0.0 }, |
| 357 | .color = clear_value, |
| 358 | }, |
| 359 | { |
| 360 | .vue_header = { 0 }, |
| 361 | .position = { fb->width, 0.0 }, |
| 362 | .color = clear_value, |
| 363 | }, |
| 364 | { |
| 365 | .vue_header = { 0 }, |
| 366 | .position = { fb->width, fb->height }, |
| 367 | .color = clear_value, |
| 368 | }, |
| 369 | }; |
| 370 | |
| 371 | struct anv_state state = |
Kristian Høgsberg | 7735920 | 2015-12-01 15:37:12 -0800 | [diff] [blame] | 372 | anv_cmd_buffer_emit_dynamic(cmd_buffer, vertex_data, sizeof(vertex_data), 16); |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 373 | |
| 374 | struct anv_buffer vertex_buffer = { |
| 375 | .device = device, |
| 376 | .size = sizeof(vertex_data), |
| 377 | .bo = &device->dynamic_state_block_pool.bo, |
| 378 | .offset = state.offset, |
| 379 | }; |
| 380 | |
BogDan Vatra | 102c742 | 2016-01-05 21:44:16 +0200 | [diff] [blame] | 381 | ANV_CALL(CmdSetViewport)(cmd_buffer_h, 0, 1, |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 382 | (VkViewport[]) { |
| 383 | { |
Jason Ekstrand | 5f348bd | 2015-11-30 17:26:32 -0800 | [diff] [blame] | 384 | .x = 0, |
| 385 | .y = 0, |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 386 | .width = fb->width, |
| 387 | .height = fb->height, |
| 388 | .minDepth = 0.0, |
| 389 | .maxDepth = 1.0, |
| 390 | }, |
| 391 | }); |
| 392 | |
BogDan Vatra | 102c742 | 2016-01-05 21:44:16 +0200 | [diff] [blame] | 393 | ANV_CALL(CmdSetScissor)(cmd_buffer_h, 0, 1, |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 394 | (VkRect2D[]) { |
| 395 | { |
| 396 | .offset = { 0, 0 }, |
| 397 | .extent = { fb->width, fb->height }, |
| 398 | } |
| 399 | }); |
| 400 | |
| 401 | ANV_CALL(CmdBindVertexBuffers)(cmd_buffer_h, 0, 1, |
| 402 | (VkBuffer[]) { anv_buffer_to_handle(&vertex_buffer) }, |
| 403 | (VkDeviceSize[]) { 0 }); |
| 404 | |
Chad Versace | 0679bef | 2016-01-13 16:29:45 -0800 | [diff] [blame] | 405 | if (cmd_buffer->state.pipeline != pipeline) { |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 406 | ANV_CALL(CmdBindPipeline)(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 407 | pipeline_h); |
| 408 | } |
| 409 | |
| 410 | ANV_CALL(CmdDraw)(cmd_buffer_h, 3, 1, 0, 0); |
| 411 | } |
| 412 | |
| 413 | |
| 414 | static void |
| 415 | build_depthstencil_shaders(struct nir_shader **out_vs, |
| 416 | struct nir_shader **out_fs) |
| 417 | { |
| 418 | nir_builder vs_b; |
| 419 | nir_builder fs_b; |
| 420 | |
Jason Ekstrand | a33fcc0 | 2015-12-29 13:47:37 -0800 | [diff] [blame] | 421 | nir_builder_init_simple_shader(&vs_b, NULL, MESA_SHADER_VERTEX, NULL); |
| 422 | nir_builder_init_simple_shader(&fs_b, NULL, MESA_SHADER_FRAGMENT, NULL); |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 423 | |
Chad Versace | 13610c0 | 2016-01-13 18:09:01 -0800 | [diff] [blame] | 424 | vs_b.shader->info.name = ralloc_strdup(vs_b.shader, "meta_clear_depthstencil_vs"); |
| 425 | fs_b.shader->info.name = ralloc_strdup(fs_b.shader, "meta_clear_depthstencil_fs"); |
| 426 | |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 427 | const struct glsl_type *position_type = glsl_vec4_type(); |
| 428 | |
| 429 | nir_variable *vs_in_pos = |
| 430 | nir_variable_create(vs_b.shader, nir_var_shader_in, position_type, |
| 431 | "a_position"); |
| 432 | vs_in_pos->data.location = VERT_ATTRIB_GENERIC0; |
| 433 | |
| 434 | nir_variable *vs_out_pos = |
| 435 | nir_variable_create(vs_b.shader, nir_var_shader_out, position_type, |
| 436 | "gl_Position"); |
| 437 | vs_out_pos->data.location = VARYING_SLOT_POS; |
| 438 | |
| 439 | nir_copy_var(&vs_b, vs_out_pos, vs_in_pos); |
| 440 | |
| 441 | *out_vs = vs_b.shader; |
| 442 | *out_fs = fs_b.shader; |
| 443 | } |
| 444 | |
Kristian Høgsberg Kristensen | 5526c17 | 2016-01-03 22:43:47 -0800 | [diff] [blame] | 445 | static VkResult |
Chad Versace | 16119ad | 2015-11-04 17:00:01 -0800 | [diff] [blame] | 446 | create_depthstencil_pipeline(struct anv_device *device, |
Kristian Høgsberg Kristensen | 5526c17 | 2016-01-03 22:43:47 -0800 | [diff] [blame] | 447 | VkImageAspectFlags aspects, |
| 448 | struct anv_pipeline **pipeline) |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 449 | { |
| 450 | struct nir_shader *vs_nir; |
| 451 | struct nir_shader *fs_nir; |
Chad Versace | 16119ad | 2015-11-04 17:00:01 -0800 | [diff] [blame] | 452 | |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 453 | build_depthstencil_shaders(&vs_nir, &fs_nir); |
| 454 | |
| 455 | const VkPipelineVertexInputStateCreateInfo vi_state = { |
| 456 | .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, |
Jason Ekstrand | e673d64 | 2015-11-30 17:00:30 -0800 | [diff] [blame] | 457 | .vertexBindingDescriptionCount = 1, |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 458 | .pVertexBindingDescriptions = (VkVertexInputBindingDescription[]) { |
| 459 | { |
| 460 | .binding = 0, |
Jason Ekstrand | e673d64 | 2015-11-30 17:00:30 -0800 | [diff] [blame] | 461 | .stride = sizeof(struct depthstencil_clear_vattrs), |
Jason Ekstrand | 9b1cb8f | 2015-11-30 13:28:09 -0800 | [diff] [blame] | 462 | .inputRate = VK_VERTEX_INPUT_RATE_VERTEX |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 463 | }, |
| 464 | }, |
Jason Ekstrand | e673d64 | 2015-11-30 17:00:30 -0800 | [diff] [blame] | 465 | .vertexAttributeDescriptionCount = 2, |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 466 | .pVertexAttributeDescriptions = (VkVertexInputAttributeDescription[]) { |
| 467 | { |
| 468 | /* VUE Header */ |
| 469 | .location = 0, |
| 470 | .binding = 0, |
| 471 | .format = VK_FORMAT_R32G32B32A32_UINT, |
Jason Ekstrand | e673d64 | 2015-11-30 17:00:30 -0800 | [diff] [blame] | 472 | .offset = offsetof(struct depthstencil_clear_vattrs, vue_header), |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 473 | }, |
| 474 | { |
| 475 | /* Position */ |
| 476 | .location = 1, |
| 477 | .binding = 0, |
| 478 | .format = VK_FORMAT_R32G32_SFLOAT, |
Jason Ekstrand | e673d64 | 2015-11-30 17:00:30 -0800 | [diff] [blame] | 479 | .offset = offsetof(struct depthstencil_clear_vattrs, position), |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 480 | }, |
| 481 | }, |
| 482 | }; |
| 483 | |
| 484 | const VkPipelineDepthStencilStateCreateInfo ds_state = { |
| 485 | .sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, |
Chad Versace | 16119ad | 2015-11-04 17:00:01 -0800 | [diff] [blame] | 486 | .depthTestEnable = (aspects & VK_IMAGE_ASPECT_DEPTH_BIT), |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 487 | .depthCompareOp = VK_COMPARE_OP_ALWAYS, |
Chad Versace | 16119ad | 2015-11-04 17:00:01 -0800 | [diff] [blame] | 488 | .depthWriteEnable = (aspects & VK_IMAGE_ASPECT_DEPTH_BIT), |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 489 | .depthBoundsTestEnable = false, |
Chad Versace | 16119ad | 2015-11-04 17:00:01 -0800 | [diff] [blame] | 490 | .stencilTestEnable = (aspects & VK_IMAGE_ASPECT_STENCIL_BIT), |
| 491 | .front = { |
Jason Ekstrand | 4ab9391 | 2015-11-30 14:19:41 -0800 | [diff] [blame] | 492 | .passOp = VK_STENCIL_OP_REPLACE, |
| 493 | .compareOp = VK_COMPARE_OP_ALWAYS, |
| 494 | .writeMask = UINT32_MAX, |
| 495 | .reference = 0, /* dynamic */ |
Chad Versace | 16119ad | 2015-11-04 17:00:01 -0800 | [diff] [blame] | 496 | }, |
| 497 | .back = { 0 /* dont care */ }, |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 498 | }; |
| 499 | |
| 500 | const VkPipelineColorBlendStateCreateInfo cb_state = { |
| 501 | .sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 502 | .logicOpEnable = false, |
| 503 | .attachmentCount = 0, |
| 504 | .pAttachments = NULL, |
| 505 | }; |
| 506 | |
Chad Versace | 16119ad | 2015-11-04 17:00:01 -0800 | [diff] [blame] | 507 | return create_pipeline(device, vs_nir, fs_nir, &vi_state, &ds_state, |
Chad Versace | 0679bef | 2016-01-13 16:29:45 -0800 | [diff] [blame] | 508 | &cb_state, NULL, /*use_repclear*/ true, pipeline); |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 509 | } |
| 510 | |
| 511 | static void |
Chad Versace | f2700d6 | 2016-01-13 14:09:36 -0800 | [diff] [blame] | 512 | emit_depthstencil_clear(struct anv_cmd_buffer *cmd_buffer, |
Chad Versace | deb8dd8 | 2016-01-13 14:47:51 -0800 | [diff] [blame^] | 513 | const VkClearAttachment *clear_att) |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 514 | { |
| 515 | struct anv_device *device = cmd_buffer->device; |
Chad Versace | deb8dd8 | 2016-01-13 14:47:51 -0800 | [diff] [blame^] | 516 | const struct anv_subpass *subpass = cmd_buffer->state.subpass; |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 517 | const struct anv_framebuffer *fb = cmd_buffer->state.framebuffer; |
Chad Versace | deb8dd8 | 2016-01-13 14:47:51 -0800 | [diff] [blame^] | 518 | uint32_t attachment = subpass->depth_stencil_attachment; |
| 519 | VkClearDepthStencilValue clear_value = clear_att->clearValue.depthStencil; |
| 520 | VkImageAspectFlags aspects = clear_att->aspectMask; |
| 521 | |
| 522 | VkCommandBuffer cmd_buffer_h = anv_cmd_buffer_to_handle(cmd_buffer); |
| 523 | |
| 524 | assert(aspects == VK_IMAGE_ASPECT_DEPTH_BIT || |
| 525 | aspects == VK_IMAGE_ASPECT_STENCIL_BIT || |
| 526 | aspects == (VK_IMAGE_ASPECT_DEPTH_BIT | |
| 527 | VK_IMAGE_ASPECT_STENCIL_BIT)); |
| 528 | assert(attachment != VK_ATTACHMENT_UNUSED); |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 529 | |
Chad Versace | 16119ad | 2015-11-04 17:00:01 -0800 | [diff] [blame] | 530 | const struct depthstencil_clear_vattrs vertex_data[3] = { |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 531 | { |
| 532 | .vue_header = { 0 }, |
| 533 | .position = { 0.0, 0.0 }, |
| 534 | }, |
| 535 | { |
| 536 | .vue_header = { 0 }, |
| 537 | .position = { fb->width, 0.0 }, |
| 538 | }, |
| 539 | { |
| 540 | .vue_header = { 0 }, |
| 541 | .position = { fb->width, fb->height }, |
| 542 | }, |
| 543 | }; |
| 544 | |
| 545 | struct anv_state state = |
Kristian Høgsberg | 7735920 | 2015-12-01 15:37:12 -0800 | [diff] [blame] | 546 | anv_cmd_buffer_emit_dynamic(cmd_buffer, vertex_data, sizeof(vertex_data), 16); |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 547 | |
| 548 | struct anv_buffer vertex_buffer = { |
| 549 | .device = device, |
| 550 | .size = sizeof(vertex_data), |
| 551 | .bo = &device->dynamic_state_block_pool.bo, |
| 552 | .offset = state.offset, |
| 553 | }; |
| 554 | |
BogDan Vatra | 102c742 | 2016-01-05 21:44:16 +0200 | [diff] [blame] | 555 | ANV_CALL(CmdSetViewport)(cmd_buffer_h, 0, 1, |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 556 | (VkViewport[]) { |
| 557 | { |
Jason Ekstrand | 5f348bd | 2015-11-30 17:26:32 -0800 | [diff] [blame] | 558 | .x = 0, |
| 559 | .y = 0, |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 560 | .width = fb->width, |
| 561 | .height = fb->height, |
Chad Versace | 16119ad | 2015-11-04 17:00:01 -0800 | [diff] [blame] | 562 | |
| 563 | /* Ignored when clearing only stencil. */ |
| 564 | .minDepth = clear_value.depth, |
| 565 | .maxDepth = clear_value.depth, |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 566 | }, |
| 567 | }); |
| 568 | |
BogDan Vatra | 102c742 | 2016-01-05 21:44:16 +0200 | [diff] [blame] | 569 | ANV_CALL(CmdSetScissor)(cmd_buffer_h, 0, 1, |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 570 | (VkRect2D[]) { |
| 571 | { |
| 572 | .offset = { 0, 0 }, |
| 573 | .extent = { fb->width, fb->height }, |
| 574 | } |
| 575 | }); |
| 576 | |
Chad Versace | 16119ad | 2015-11-04 17:00:01 -0800 | [diff] [blame] | 577 | if (aspects & VK_IMAGE_ASPECT_STENCIL_BIT) { |
| 578 | ANV_CALL(CmdSetStencilReference)(cmd_buffer_h, VK_STENCIL_FACE_FRONT_BIT, |
| 579 | clear_value.stencil); |
| 580 | } |
| 581 | |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 582 | ANV_CALL(CmdBindVertexBuffers)(cmd_buffer_h, 0, 1, |
| 583 | (VkBuffer[]) { anv_buffer_to_handle(&vertex_buffer) }, |
| 584 | (VkDeviceSize[]) { 0 }); |
| 585 | |
Chad Versace | 16119ad | 2015-11-04 17:00:01 -0800 | [diff] [blame] | 586 | struct anv_pipeline *pipeline; |
| 587 | switch (aspects) { |
| 588 | case VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT: |
| 589 | pipeline = device->meta_state.clear.depthstencil_pipeline; |
| 590 | break; |
| 591 | case VK_IMAGE_ASPECT_DEPTH_BIT: |
| 592 | pipeline = device->meta_state.clear.depth_only_pipeline; |
| 593 | break; |
| 594 | case VK_IMAGE_ASPECT_STENCIL_BIT: |
| 595 | pipeline = device->meta_state.clear.stencil_only_pipeline; |
| 596 | break; |
| 597 | default: |
| 598 | unreachable("expected depth or stencil aspect"); |
| 599 | } |
| 600 | |
| 601 | if (cmd_buffer->state.pipeline != pipeline) { |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 602 | ANV_CALL(CmdBindPipeline)(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS, |
Chad Versace | 16119ad | 2015-11-04 17:00:01 -0800 | [diff] [blame] | 603 | anv_pipeline_to_handle(pipeline)); |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | ANV_CALL(CmdDraw)(cmd_buffer_h, 3, 1, 0, 0); |
| 607 | } |
| 608 | |
Kristian Høgsberg Kristensen | 5526c17 | 2016-01-03 22:43:47 -0800 | [diff] [blame] | 609 | static VkResult |
Chad Versace | 16119ad | 2015-11-04 17:00:01 -0800 | [diff] [blame] | 610 | init_depthstencil_pipelines(struct anv_device *device) |
| 611 | { |
Kristian Høgsberg Kristensen | 5526c17 | 2016-01-03 22:43:47 -0800 | [diff] [blame] | 612 | VkResult result; |
| 613 | struct anv_meta_state *state = &device->meta_state; |
Chad Versace | 16119ad | 2015-11-04 17:00:01 -0800 | [diff] [blame] | 614 | |
Kristian Høgsberg Kristensen | 5526c17 | 2016-01-03 22:43:47 -0800 | [diff] [blame] | 615 | result = |
| 616 | create_depthstencil_pipeline(device, VK_IMAGE_ASPECT_DEPTH_BIT, |
| 617 | &state->clear.depth_only_pipeline); |
| 618 | if (result != VK_SUCCESS) |
| 619 | goto fail; |
Chad Versace | 16119ad | 2015-11-04 17:00:01 -0800 | [diff] [blame] | 620 | |
Kristian Høgsberg Kristensen | 5526c17 | 2016-01-03 22:43:47 -0800 | [diff] [blame] | 621 | result = |
| 622 | create_depthstencil_pipeline(device, VK_IMAGE_ASPECT_STENCIL_BIT, |
| 623 | &state->clear.stencil_only_pipeline); |
| 624 | if (result != VK_SUCCESS) |
| 625 | goto fail_depth_only; |
| 626 | |
| 627 | result = |
| 628 | create_depthstencil_pipeline(device, |
| 629 | VK_IMAGE_ASPECT_DEPTH_BIT | |
| 630 | VK_IMAGE_ASPECT_STENCIL_BIT, |
| 631 | &state->clear.depthstencil_pipeline); |
| 632 | if (result != VK_SUCCESS) |
| 633 | goto fail_stencil_only; |
| 634 | |
| 635 | return result; |
| 636 | |
| 637 | fail_stencil_only: |
| 638 | anv_DestroyPipeline(anv_device_to_handle(device), |
| 639 | anv_pipeline_to_handle(state->clear.stencil_only_pipeline), |
| 640 | NULL); |
| 641 | fail_depth_only: |
| 642 | anv_DestroyPipeline(anv_device_to_handle(device), |
| 643 | anv_pipeline_to_handle(state->clear.depth_only_pipeline), |
| 644 | NULL); |
| 645 | fail: |
| 646 | return result; |
Chad Versace | 16119ad | 2015-11-04 17:00:01 -0800 | [diff] [blame] | 647 | } |
| 648 | |
Kristian Høgsberg Kristensen | 5526c17 | 2016-01-03 22:43:47 -0800 | [diff] [blame] | 649 | VkResult |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 650 | anv_device_init_meta_clear_state(struct anv_device *device) |
| 651 | { |
Kristian Høgsberg Kristensen | 5526c17 | 2016-01-03 22:43:47 -0800 | [diff] [blame] | 652 | VkResult result; |
| 653 | |
Chad Versace | 0679bef | 2016-01-13 16:29:45 -0800 | [diff] [blame] | 654 | result = init_color_pipelines(device); |
Kristian Høgsberg Kristensen | 5526c17 | 2016-01-03 22:43:47 -0800 | [diff] [blame] | 655 | if (result != VK_SUCCESS) |
Chad Versace | 0679bef | 2016-01-13 16:29:45 -0800 | [diff] [blame] | 656 | return result; |
Kristian Høgsberg Kristensen | 5526c17 | 2016-01-03 22:43:47 -0800 | [diff] [blame] | 657 | |
| 658 | result = init_depthstencil_pipelines(device); |
| 659 | if (result != VK_SUCCESS) |
Chad Versace | 0679bef | 2016-01-13 16:29:45 -0800 | [diff] [blame] | 660 | return result; |
Kristian Høgsberg Kristensen | 5526c17 | 2016-01-03 22:43:47 -0800 | [diff] [blame] | 661 | |
| 662 | return VK_SUCCESS; |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 663 | } |
| 664 | |
| 665 | void |
| 666 | anv_device_finish_meta_clear_state(struct anv_device *device) |
| 667 | { |
Chad Versace | 16119ad | 2015-11-04 17:00:01 -0800 | [diff] [blame] | 668 | VkDevice device_h = anv_device_to_handle(device); |
| 669 | |
Chad Versace | 0679bef | 2016-01-13 16:29:45 -0800 | [diff] [blame] | 670 | for (uint32_t i = 0; |
| 671 | i < ARRAY_SIZE(device->meta_state.clear.color_pipelines); ++i) { |
| 672 | ANV_CALL(DestroyPipeline)(device_h, |
| 673 | anv_pipeline_to_handle(device->meta_state.clear.color_pipelines[i]), |
| 674 | NULL); |
| 675 | } |
| 676 | |
Chad Versace | 16119ad | 2015-11-04 17:00:01 -0800 | [diff] [blame] | 677 | ANV_CALL(DestroyPipeline)(device_h, |
Jason Ekstrand | fcfb404 | 2015-12-02 03:28:27 -0800 | [diff] [blame] | 678 | anv_pipeline_to_handle(device->meta_state.clear.depth_only_pipeline), |
| 679 | NULL); |
Chad Versace | 16119ad | 2015-11-04 17:00:01 -0800 | [diff] [blame] | 680 | ANV_CALL(DestroyPipeline)(device_h, |
Jason Ekstrand | fcfb404 | 2015-12-02 03:28:27 -0800 | [diff] [blame] | 681 | anv_pipeline_to_handle(device->meta_state.clear.stencil_only_pipeline), |
| 682 | NULL); |
Chad Versace | 16119ad | 2015-11-04 17:00:01 -0800 | [diff] [blame] | 683 | ANV_CALL(DestroyPipeline)(device_h, |
Jason Ekstrand | fcfb404 | 2015-12-02 03:28:27 -0800 | [diff] [blame] | 684 | anv_pipeline_to_handle(device->meta_state.clear.depthstencil_pipeline), |
| 685 | NULL); |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 686 | } |
| 687 | |
Chad Versace | 356f952 | 2016-01-13 11:52:23 -0800 | [diff] [blame] | 688 | /** |
Chad Versace | deb8dd8 | 2016-01-13 14:47:51 -0800 | [diff] [blame^] | 689 | * The parameters mean that same as those in vkCmdClearAttachments. |
Chad Versace | 356f952 | 2016-01-13 11:52:23 -0800 | [diff] [blame] | 690 | */ |
| 691 | static void |
| 692 | emit_clear(struct anv_cmd_buffer *cmd_buffer, |
Chad Versace | deb8dd8 | 2016-01-13 14:47:51 -0800 | [diff] [blame^] | 693 | const VkClearAttachment *clear_att) |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 694 | { |
Chad Versace | deb8dd8 | 2016-01-13 14:47:51 -0800 | [diff] [blame^] | 695 | if (clear_att->aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) { |
| 696 | emit_color_clear(cmd_buffer, clear_att); |
Chad Versace | 356f952 | 2016-01-13 11:52:23 -0800 | [diff] [blame] | 697 | } else { |
Chad Versace | deb8dd8 | 2016-01-13 14:47:51 -0800 | [diff] [blame^] | 698 | assert(clear_att->aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | |
| 699 | VK_IMAGE_ASPECT_STENCIL_BIT)); |
| 700 | emit_depthstencil_clear(cmd_buffer, clear_att); |
Chad Versace | 356f952 | 2016-01-13 11:52:23 -0800 | [diff] [blame] | 701 | } |
| 702 | } |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 703 | |
Chad Versace | 356f952 | 2016-01-13 11:52:23 -0800 | [diff] [blame] | 704 | static bool |
Chad Versace | deb8dd8 | 2016-01-13 14:47:51 -0800 | [diff] [blame^] | 705 | subpass_needs_clear(const struct anv_cmd_buffer *cmd_buffer) |
Chad Versace | 356f952 | 2016-01-13 11:52:23 -0800 | [diff] [blame] | 706 | { |
| 707 | const struct anv_cmd_state *cmd_state = &cmd_buffer->state; |
Chad Versace | deb8dd8 | 2016-01-13 14:47:51 -0800 | [diff] [blame^] | 708 | uint32_t ds = cmd_state->subpass->depth_stencil_attachment; |
Jason Ekstrand | e14b2c7 | 2015-11-21 11:39:12 -0800 | [diff] [blame] | 709 | |
Chad Versace | deb8dd8 | 2016-01-13 14:47:51 -0800 | [diff] [blame^] | 710 | for (uint32_t i = 0; i < cmd_state->subpass->color_count; ++i) { |
| 711 | uint32_t a = cmd_state->subpass->color_attachments[i]; |
| 712 | if (cmd_state->attachments[a].pending_clear_aspects) { |
Chad Versace | 356f952 | 2016-01-13 11:52:23 -0800 | [diff] [blame] | 713 | return true; |
Jason Ekstrand | e14b2c7 | 2015-11-21 11:39:12 -0800 | [diff] [blame] | 714 | } |
| 715 | } |
| 716 | |
Chad Versace | deb8dd8 | 2016-01-13 14:47:51 -0800 | [diff] [blame^] | 717 | if (ds != VK_ATTACHMENT_UNUSED && |
| 718 | cmd_state->attachments[ds].pending_clear_aspects) { |
| 719 | return true; |
| 720 | } |
| 721 | |
Chad Versace | 356f952 | 2016-01-13 11:52:23 -0800 | [diff] [blame] | 722 | return false; |
| 723 | } |
| 724 | |
Chad Versace | deb8dd8 | 2016-01-13 14:47:51 -0800 | [diff] [blame^] | 725 | /** |
| 726 | * Emit any pending attachment clears for the current subpass. |
| 727 | * |
| 728 | * @see anv_attachment_state::pending_clear_aspects |
| 729 | */ |
Chad Versace | 356f952 | 2016-01-13 11:52:23 -0800 | [diff] [blame] | 730 | void |
Chad Versace | deb8dd8 | 2016-01-13 14:47:51 -0800 | [diff] [blame^] | 731 | anv_cmd_buffer_clear_subpass(struct anv_cmd_buffer *cmd_buffer) |
Chad Versace | 356f952 | 2016-01-13 11:52:23 -0800 | [diff] [blame] | 732 | { |
| 733 | struct anv_cmd_state *cmd_state = &cmd_buffer->state; |
| 734 | struct anv_meta_saved_state saved_state; |
| 735 | |
Chad Versace | deb8dd8 | 2016-01-13 14:47:51 -0800 | [diff] [blame^] | 736 | if (!subpass_needs_clear(cmd_buffer)) |
Jason Ekstrand | e14b2c7 | 2015-11-21 11:39:12 -0800 | [diff] [blame] | 737 | return; |
| 738 | |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 739 | meta_clear_begin(&saved_state, cmd_buffer); |
| 740 | |
Chad Versace | 356f952 | 2016-01-13 11:52:23 -0800 | [diff] [blame] | 741 | if (cmd_state->framebuffer->layers > 1) |
Chad Versace | 0415dfc | 2016-01-11 15:05:47 -0800 | [diff] [blame] | 742 | anv_finishme("clearing multi-layer framebuffer"); |
| 743 | |
Chad Versace | deb8dd8 | 2016-01-13 14:47:51 -0800 | [diff] [blame^] | 744 | for (uint32_t i = 0; i < cmd_state->subpass->color_count; ++i) { |
| 745 | uint32_t a = cmd_state->subpass->color_attachments[i]; |
| 746 | |
Chad Versace | 356f952 | 2016-01-13 11:52:23 -0800 | [diff] [blame] | 747 | if (!cmd_state->attachments[a].pending_clear_aspects) |
| 748 | continue; |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 749 | |
Chad Versace | deb8dd8 | 2016-01-13 14:47:51 -0800 | [diff] [blame^] | 750 | assert(cmd_state->attachments[a].pending_clear_aspects == |
| 751 | VK_IMAGE_ASPECT_COLOR_BIT); |
Chad Versace | 16119ad | 2015-11-04 17:00:01 -0800 | [diff] [blame] | 752 | |
Chad Versace | deb8dd8 | 2016-01-13 14:47:51 -0800 | [diff] [blame^] | 753 | VkClearAttachment clear_att = { |
| 754 | .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, |
| 755 | .colorAttachment = i, /* Use attachment index relative to subpass */ |
| 756 | .clearValue = cmd_state->attachments[a].clear_value, |
| 757 | }; |
| 758 | |
| 759 | emit_clear(cmd_buffer, &clear_att); |
Chad Versace | 356f952 | 2016-01-13 11:52:23 -0800 | [diff] [blame] | 760 | cmd_state->attachments[a].pending_clear_aspects = 0; |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 761 | } |
| 762 | |
Chad Versace | deb8dd8 | 2016-01-13 14:47:51 -0800 | [diff] [blame^] | 763 | uint32_t ds = cmd_state->subpass->depth_stencil_attachment; |
| 764 | |
| 765 | if (ds != VK_ATTACHMENT_UNUSED && |
| 766 | cmd_state->attachments[ds].pending_clear_aspects) { |
| 767 | |
| 768 | VkClearAttachment clear_att = { |
| 769 | .aspectMask = cmd_state->attachments[ds].pending_clear_aspects, |
| 770 | .clearValue = cmd_state->attachments[ds].clear_value, |
| 771 | }; |
| 772 | |
| 773 | emit_clear(cmd_buffer, &clear_att); |
| 774 | cmd_state->attachments[ds].pending_clear_aspects = 0; |
| 775 | } |
| 776 | |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 777 | meta_clear_end(&saved_state, cmd_buffer); |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 778 | } |
| 779 | |
| 780 | void anv_CmdClearColorImage( |
Jason Ekstrand | a89a485 | 2015-11-30 11:48:08 -0800 | [diff] [blame] | 781 | VkCommandBuffer commandBuffer, |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 782 | VkImage _image, |
| 783 | VkImageLayout imageLayout, |
| 784 | const VkClearColorValue* pColor, |
| 785 | uint32_t rangeCount, |
| 786 | const VkImageSubresourceRange* pRanges) |
| 787 | { |
Jason Ekstrand | a89a485 | 2015-11-30 11:48:08 -0800 | [diff] [blame] | 788 | ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer); |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 789 | ANV_FROM_HANDLE(anv_image, image, _image); |
| 790 | struct anv_meta_saved_state saved_state; |
| 791 | |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 792 | meta_clear_begin(&saved_state, cmd_buffer); |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 793 | |
| 794 | for (uint32_t r = 0; r < rangeCount; r++) { |
Jason Ekstrand | 299f8f1 | 2015-12-01 12:52:56 -0800 | [diff] [blame] | 795 | for (uint32_t l = 0; l < pRanges[r].levelCount; l++) { |
| 796 | for (uint32_t s = 0; s < pRanges[r].layerCount; s++) { |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 797 | struct anv_image_view iview; |
| 798 | anv_image_view_init(&iview, cmd_buffer->device, |
| 799 | &(VkImageViewCreateInfo) { |
| 800 | .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, |
| 801 | .image = _image, |
Chad Versace | f0d11d5 | 2015-12-09 17:03:14 -0800 | [diff] [blame] | 802 | .viewType = anv_meta_get_view_type(image), |
Jason Ekstrand | 3200a81 | 2015-12-31 12:39:34 -0800 | [diff] [blame] | 803 | .format = image->vk_format, |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 804 | .subresourceRange = { |
| 805 | .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, |
| 806 | .baseMipLevel = pRanges[r].baseMipLevel + l, |
Jason Ekstrand | 299f8f1 | 2015-12-01 12:52:56 -0800 | [diff] [blame] | 807 | .levelCount = 1, |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 808 | .baseArrayLayer = pRanges[r].baseArrayLayer + s, |
Jason Ekstrand | 299f8f1 | 2015-12-01 12:52:56 -0800 | [diff] [blame] | 809 | .layerCount = 1 |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 810 | }, |
| 811 | }, |
| 812 | cmd_buffer); |
| 813 | |
| 814 | VkFramebuffer fb; |
| 815 | anv_CreateFramebuffer(anv_device_to_handle(cmd_buffer->device), |
| 816 | &(VkFramebufferCreateInfo) { |
| 817 | .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, |
| 818 | .attachmentCount = 1, |
| 819 | .pAttachments = (VkImageView[]) { |
| 820 | anv_image_view_to_handle(&iview), |
| 821 | }, |
| 822 | .width = iview.extent.width, |
| 823 | .height = iview.extent.height, |
| 824 | .layers = 1 |
Jason Ekstrand | fcfb404 | 2015-12-02 03:28:27 -0800 | [diff] [blame] | 825 | }, &cmd_buffer->pool->alloc, &fb); |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 826 | |
| 827 | VkRenderPass pass; |
| 828 | anv_CreateRenderPass(anv_device_to_handle(cmd_buffer->device), |
| 829 | &(VkRenderPassCreateInfo) { |
| 830 | .sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, |
| 831 | .attachmentCount = 1, |
| 832 | .pAttachments = &(VkAttachmentDescription) { |
Jason Ekstrand | f665fdf | 2016-01-01 14:09:17 -0800 | [diff] [blame] | 833 | .format = iview.vk_format, |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 834 | .loadOp = VK_ATTACHMENT_LOAD_OP_LOAD, |
| 835 | .storeOp = VK_ATTACHMENT_STORE_OP_STORE, |
| 836 | .initialLayout = VK_IMAGE_LAYOUT_GENERAL, |
| 837 | .finalLayout = VK_IMAGE_LAYOUT_GENERAL, |
| 838 | }, |
| 839 | .subpassCount = 1, |
| 840 | .pSubpasses = &(VkSubpassDescription) { |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 841 | .pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS, |
Jason Ekstrand | 43f3e92 | 2015-12-01 13:09:22 -0800 | [diff] [blame] | 842 | .inputAttachmentCount = 0, |
| 843 | .colorAttachmentCount = 1, |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 844 | .pColorAttachments = &(VkAttachmentReference) { |
| 845 | .attachment = 0, |
| 846 | .layout = VK_IMAGE_LAYOUT_GENERAL, |
| 847 | }, |
| 848 | .pResolveAttachments = NULL, |
Jason Ekstrand | 43f3e92 | 2015-12-01 13:09:22 -0800 | [diff] [blame] | 849 | .pDepthStencilAttachment = &(VkAttachmentReference) { |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 850 | .attachment = VK_ATTACHMENT_UNUSED, |
| 851 | .layout = VK_IMAGE_LAYOUT_GENERAL, |
| 852 | }, |
Jason Ekstrand | 43f3e92 | 2015-12-01 13:09:22 -0800 | [diff] [blame] | 853 | .preserveAttachmentCount = 1, |
Jason Ekstrand | 7b81637 | 2016-01-14 07:29:58 -0800 | [diff] [blame] | 854 | .pPreserveAttachments = (uint32_t[]) { 0 }, |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 855 | }, |
| 856 | .dependencyCount = 0, |
Jason Ekstrand | fcfb404 | 2015-12-02 03:28:27 -0800 | [diff] [blame] | 857 | }, &cmd_buffer->pool->alloc, &pass); |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 858 | |
| 859 | ANV_CALL(CmdBeginRenderPass)(anv_cmd_buffer_to_handle(cmd_buffer), |
| 860 | &(VkRenderPassBeginInfo) { |
| 861 | .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, |
| 862 | .renderArea = { |
| 863 | .offset = { 0, 0, }, |
| 864 | .extent = { |
| 865 | .width = iview.extent.width, |
| 866 | .height = iview.extent.height, |
| 867 | }, |
| 868 | }, |
| 869 | .renderPass = pass, |
| 870 | .framebuffer = fb, |
| 871 | .clearValueCount = 1, |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 872 | .pClearValues = (VkClearValue[]) { |
| 873 | { .color = *pColor }, |
| 874 | }, |
Jason Ekstrand | a89a485 | 2015-11-30 11:48:08 -0800 | [diff] [blame] | 875 | }, VK_SUBPASS_CONTENTS_INLINE); |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 876 | |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 877 | ANV_CALL(CmdEndRenderPass)(anv_cmd_buffer_to_handle(cmd_buffer)); |
Jason Ekstrand | fcfb404 | 2015-12-02 03:28:27 -0800 | [diff] [blame] | 878 | |
| 879 | /* XXX: We're leaking the render pass and framebuffer */ |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 880 | } |
| 881 | } |
| 882 | } |
| 883 | |
Chad Versace | a9a3071 | 2015-11-03 14:55:58 -0800 | [diff] [blame] | 884 | meta_clear_end(&saved_state, cmd_buffer); |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 885 | } |
| 886 | |
| 887 | void anv_CmdClearDepthStencilImage( |
Jason Ekstrand | a89a485 | 2015-11-30 11:48:08 -0800 | [diff] [blame] | 888 | VkCommandBuffer commandBuffer, |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 889 | VkImage image, |
| 890 | VkImageLayout imageLayout, |
| 891 | const VkClearDepthStencilValue* pDepthStencil, |
| 892 | uint32_t rangeCount, |
| 893 | const VkImageSubresourceRange* pRanges) |
| 894 | { |
| 895 | stub(); |
| 896 | } |
| 897 | |
Jason Ekstrand | 569f70b | 2015-11-30 14:52:38 -0800 | [diff] [blame] | 898 | void anv_CmdClearAttachments( |
Jason Ekstrand | a89a485 | 2015-11-30 11:48:08 -0800 | [diff] [blame] | 899 | VkCommandBuffer commandBuffer, |
Jason Ekstrand | 569f70b | 2015-11-30 14:52:38 -0800 | [diff] [blame] | 900 | uint32_t attachmentCount, |
| 901 | const VkClearAttachment* pAttachments, |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 902 | uint32_t rectCount, |
Jason Ekstrand | 569f70b | 2015-11-30 14:52:38 -0800 | [diff] [blame] | 903 | const VkClearRect* pRects) |
Chad Versace | 16b2a48 | 2015-11-03 14:19:45 -0800 | [diff] [blame] | 904 | { |
| 905 | stub(); |
| 906 | } |