diff options
author | Jason Ekstrand <[email protected]> | 2016-10-07 15:06:47 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2016-10-14 15:40:39 -0700 |
commit | dedc406ec8adc6a36eb2b37e3f565aaa1dce6e3f (patch) | |
tree | 00ab93a85c96886b33f42fe248c392d12bb89402 /src | |
parent | d823f92970447859c4891728da4e48f0c9bc0044 (diff) |
anv: Get rid of meta
Signed-off-by: Jason Ekstrand <[email protected]>
Reviewed-by: Topi Pohjolainen <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/intel/vulkan/Makefile.sources | 3 | ||||
-rw-r--r-- | src/intel/vulkan/anv_device.c | 6 | ||||
-rw-r--r-- | src/intel/vulkan/anv_meta.c | 155 | ||||
-rw-r--r-- | src/intel/vulkan/anv_meta.h | 72 | ||||
-rw-r--r-- | src/intel/vulkan/anv_meta_clear.c | 455 | ||||
-rw-r--r-- | src/intel/vulkan/anv_pipeline.c | 6 | ||||
-rw-r--r-- | src/intel/vulkan/anv_private.h | 70 |
7 files changed, 2 insertions, 765 deletions
diff --git a/src/intel/vulkan/Makefile.sources b/src/intel/vulkan/Makefile.sources index dfebe05e000..85df8a5bcf3 100644 --- a/src/intel/vulkan/Makefile.sources +++ b/src/intel/vulkan/Makefile.sources @@ -31,9 +31,6 @@ VULKAN_FILES := \ anv_genX.h \ anv_image.c \ anv_intel.c \ - anv_meta.c \ - anv_meta.h \ - anv_meta_clear.c \ anv_nir.h \ anv_nir_apply_dynamic_offsets.c \ anv_nir_apply_pipeline_layout.c \ diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 24f7227aa81..725a5720971 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -942,10 +942,6 @@ VkResult anv_CreateDevice( if (result != VK_SUCCESS) goto fail_fd; - result = anv_device_init_meta(device); - if (result != VK_SUCCESS) - goto fail_fd; - anv_device_init_blorp(device); anv_device_init_border_colors(device); @@ -972,8 +968,6 @@ void anv_DestroyDevice( anv_device_finish_blorp(device); - anv_device_finish_meta(device); - #ifdef HAVE_VALGRIND /* We only need to free these to prevent valgrind errors. The backing * BO will go away in a couple of lines so we don't actually leak. diff --git a/src/intel/vulkan/anv_meta.c b/src/intel/vulkan/anv_meta.c deleted file mode 100644 index fe07bd39e32..00000000000 --- a/src/intel/vulkan/anv_meta.c +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright © 2015 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "anv_meta.h" - -struct anv_render_pass anv_meta_dummy_renderpass = {0}; - -void -anv_meta_save(struct anv_meta_saved_state *state, - const struct anv_cmd_buffer *cmd_buffer, - uint32_t dynamic_mask) -{ - state->old_pipeline = cmd_buffer->state.pipeline; - state->old_descriptor_set0 = cmd_buffer->state.descriptors[0]; - memcpy(state->old_vertex_bindings, cmd_buffer->state.vertex_bindings, - sizeof(state->old_vertex_bindings)); - - state->dynamic_mask = dynamic_mask; - anv_dynamic_state_copy(&state->dynamic, &cmd_buffer->state.dynamic, - dynamic_mask); -} - -void -anv_meta_restore(const struct anv_meta_saved_state *state, - struct anv_cmd_buffer *cmd_buffer) -{ - cmd_buffer->state.pipeline = state->old_pipeline; - cmd_buffer->state.descriptors[0] = state->old_descriptor_set0; - memcpy(cmd_buffer->state.vertex_bindings, state->old_vertex_bindings, - sizeof(state->old_vertex_bindings)); - - cmd_buffer->state.vb_dirty |= (1 << ANV_META_VERTEX_BINDING_COUNT) - 1; - cmd_buffer->state.dirty |= ANV_CMD_DIRTY_PIPELINE; - cmd_buffer->state.descriptors_dirty |= VK_SHADER_STAGE_FRAGMENT_BIT; - - anv_dynamic_state_copy(&cmd_buffer->state.dynamic, &state->dynamic, - state->dynamic_mask); - cmd_buffer->state.dirty |= state->dynamic_mask; - - /* Since we've used the pipeline with the VS disabled, set - * need_query_wa. See CmdBeginQuery. - */ - cmd_buffer->state.need_query_wa = true; -} - -VkImageViewType -anv_meta_get_view_type(const struct anv_image *image) -{ - switch (image->type) { - case VK_IMAGE_TYPE_1D: return VK_IMAGE_VIEW_TYPE_1D; - case VK_IMAGE_TYPE_2D: return VK_IMAGE_VIEW_TYPE_2D; - case VK_IMAGE_TYPE_3D: return VK_IMAGE_VIEW_TYPE_3D; - default: - unreachable("bad VkImageViewType"); - } -} - -/** - * When creating a destination VkImageView, this function provides the needed - * VkImageViewCreateInfo::subresourceRange::baseArrayLayer. - */ -uint32_t -anv_meta_get_iview_layer(const struct anv_image *dest_image, - const VkImageSubresourceLayers *dest_subresource, - const VkOffset3D *dest_offset) -{ - switch (dest_image->type) { - case VK_IMAGE_TYPE_1D: - case VK_IMAGE_TYPE_2D: - return dest_subresource->baseArrayLayer; - case VK_IMAGE_TYPE_3D: - /* HACK: Vulkan does not allow attaching a 3D image to a framebuffer, - * but meta does it anyway. When doing so, we translate the - * destination's z offset into an array offset. - */ - return dest_offset->z; - default: - assert(!"bad VkImageType"); - return 0; - } -} - -static void * -meta_alloc(void* _device, size_t size, size_t alignment, - VkSystemAllocationScope allocationScope) -{ - struct anv_device *device = _device; - return device->alloc.pfnAllocation(device->alloc.pUserData, size, alignment, - VK_SYSTEM_ALLOCATION_SCOPE_DEVICE); -} - -static void * -meta_realloc(void* _device, void *original, size_t size, size_t alignment, - VkSystemAllocationScope allocationScope) -{ - struct anv_device *device = _device; - return device->alloc.pfnReallocation(device->alloc.pUserData, original, - size, alignment, - VK_SYSTEM_ALLOCATION_SCOPE_DEVICE); -} - -static void -meta_free(void* _device, void *data) -{ - struct anv_device *device = _device; - return device->alloc.pfnFree(device->alloc.pUserData, data); -} - -VkResult -anv_device_init_meta(struct anv_device *device) -{ - VkResult result; - - device->meta_state.alloc = (VkAllocationCallbacks) { - .pUserData = device, - .pfnAllocation = meta_alloc, - .pfnReallocation = meta_realloc, - .pfnFree = meta_free, - }; - - result = anv_device_init_meta_clear_state(device); - if (result != VK_SUCCESS) - goto fail_clear; - - return VK_SUCCESS; - -fail_clear: - return result; -} - -void -anv_device_finish_meta(struct anv_device *device) -{ - anv_device_finish_meta_clear_state(device); -} diff --git a/src/intel/vulkan/anv_meta.h b/src/intel/vulkan/anv_meta.h deleted file mode 100644 index a7cb730cf7a..00000000000 --- a/src/intel/vulkan/anv_meta.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright © 2015 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef ANV_META_H -#define ANV_META_H - -#include "anv_private.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ANV_META_VERTEX_BINDING_COUNT 2 - -struct anv_meta_saved_state { - struct anv_vertex_binding old_vertex_bindings[ANV_META_VERTEX_BINDING_COUNT]; - struct anv_descriptor_set *old_descriptor_set0; - struct anv_pipeline *old_pipeline; - - /** - * Bitmask of (1 << VK_DYNAMIC_STATE_*). Defines the set of saved dynamic - * state. - */ - uint32_t dynamic_mask; - struct anv_dynamic_state dynamic; -}; - -VkResult anv_device_init_meta_clear_state(struct anv_device *device); -void anv_device_finish_meta_clear_state(struct anv_device *device); - -void -anv_meta_save(struct anv_meta_saved_state *state, - const struct anv_cmd_buffer *cmd_buffer, - uint32_t dynamic_mask); - -void -anv_meta_restore(const struct anv_meta_saved_state *state, - struct anv_cmd_buffer *cmd_buffer); - -VkImageViewType -anv_meta_get_view_type(const struct anv_image *image); - -uint32_t -anv_meta_get_iview_layer(const struct anv_image *dest_image, - const VkImageSubresourceLayers *dest_subresource, - const VkOffset3D *dest_offset); - -#ifdef __cplusplus -} -#endif - -#endif /* ANV_META_H */ diff --git a/src/intel/vulkan/anv_meta_clear.c b/src/intel/vulkan/anv_meta_clear.c deleted file mode 100644 index 2bc718babd0..00000000000 --- a/src/intel/vulkan/anv_meta_clear.c +++ /dev/null @@ -1,455 +0,0 @@ -/* - * Copyright © 2015 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "anv_meta.h" -#include "anv_private.h" -#include "nir/nir_builder.h" - -#include "util/format_rgb9e5.h" - -/** Vertex attributes for color clears. */ -struct color_clear_vattrs { - struct anv_vue_header vue_header; - float position[2]; /**< 3DPRIM_RECTLIST */ - VkClearColorValue color; -}; - -/** Vertex attributes for depthstencil clears. */ -struct depthstencil_clear_vattrs { - struct anv_vue_header vue_header; - float position[2]; /*<< 3DPRIM_RECTLIST */ -}; - -static void -build_color_shaders(struct nir_shader **out_vs, - struct nir_shader **out_fs, - uint32_t frag_output) -{ - nir_builder vs_b; - nir_builder fs_b; - - nir_builder_init_simple_shader(&vs_b, NULL, MESA_SHADER_VERTEX, NULL); - nir_builder_init_simple_shader(&fs_b, NULL, MESA_SHADER_FRAGMENT, NULL); - - vs_b.shader->info.name = ralloc_strdup(vs_b.shader, "meta_clear_color_vs"); - fs_b.shader->info.name = ralloc_strdup(fs_b.shader, "meta_clear_color_fs"); - - const struct glsl_type *position_type = glsl_vec4_type(); - const struct glsl_type *color_type = glsl_vec4_type(); - - nir_variable *vs_in_pos = - nir_variable_create(vs_b.shader, nir_var_shader_in, position_type, - "a_position"); - vs_in_pos->data.location = VERT_ATTRIB_GENERIC0; - - nir_variable *vs_out_pos = - nir_variable_create(vs_b.shader, nir_var_shader_out, position_type, - "gl_Position"); - vs_out_pos->data.location = VARYING_SLOT_POS; - - nir_variable *vs_in_color = - nir_variable_create(vs_b.shader, nir_var_shader_in, color_type, - "a_color"); - vs_in_color->data.location = VERT_ATTRIB_GENERIC1; - - nir_variable *vs_out_color = - nir_variable_create(vs_b.shader, nir_var_shader_out, color_type, - "v_color"); - vs_out_color->data.location = VARYING_SLOT_VAR0; - vs_out_color->data.interpolation = INTERP_MODE_FLAT; - - nir_variable *fs_in_color = - nir_variable_create(fs_b.shader, nir_var_shader_in, color_type, - "v_color"); - fs_in_color->data.location = vs_out_color->data.location; - fs_in_color->data.interpolation = vs_out_color->data.interpolation; - - nir_variable *fs_out_color = - nir_variable_create(fs_b.shader, nir_var_shader_out, color_type, - "f_color"); - fs_out_color->data.location = FRAG_RESULT_DATA0 + frag_output; - - nir_copy_var(&vs_b, vs_out_pos, vs_in_pos); - nir_copy_var(&vs_b, vs_out_color, vs_in_color); - nir_copy_var(&fs_b, fs_out_color, fs_in_color); - - *out_vs = vs_b.shader; - *out_fs = fs_b.shader; -} - -static VkResult -create_pipeline(struct anv_device *device, - uint32_t samples, - struct nir_shader *vs_nir, - struct nir_shader *fs_nir, - const VkPipelineVertexInputStateCreateInfo *vi_state, - const VkPipelineDepthStencilStateCreateInfo *ds_state, - const VkPipelineColorBlendStateCreateInfo *cb_state, - const VkAllocationCallbacks *alloc, - bool use_repclear, - struct anv_pipeline **pipeline) -{ - VkDevice device_h = anv_device_to_handle(device); - VkResult result; - - struct anv_shader_module vs_m = { .nir = vs_nir }; - struct anv_shader_module fs_m = { .nir = fs_nir }; - - VkPipeline pipeline_h = VK_NULL_HANDLE; - result = anv_graphics_pipeline_create(device_h, - VK_NULL_HANDLE, - &(VkGraphicsPipelineCreateInfo) { - .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, - .stageCount = fs_nir ? 2 : 1, - .pStages = (VkPipelineShaderStageCreateInfo[]) { - { - .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, - .stage = VK_SHADER_STAGE_VERTEX_BIT, - .module = anv_shader_module_to_handle(&vs_m), - .pName = "main", - }, - { - .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, - .stage = VK_SHADER_STAGE_FRAGMENT_BIT, - .module = anv_shader_module_to_handle(&fs_m), - .pName = "main", - }, - }, - .pVertexInputState = vi_state, - .pInputAssemblyState = &(VkPipelineInputAssemblyStateCreateInfo) { - .sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, - .topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, - .primitiveRestartEnable = false, - }, - .pViewportState = &(VkPipelineViewportStateCreateInfo) { - .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, - .viewportCount = 1, - .pViewports = NULL, /* dynamic */ - .scissorCount = 1, - .pScissors = NULL, /* dynamic */ - }, - .pRasterizationState = &(VkPipelineRasterizationStateCreateInfo) { - .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, - .rasterizerDiscardEnable = false, - .polygonMode = VK_POLYGON_MODE_FILL, - .cullMode = VK_CULL_MODE_NONE, - .frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE, - .depthBiasEnable = false, - .depthClampEnable = true, - }, - .pMultisampleState = &(VkPipelineMultisampleStateCreateInfo) { - .sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, - .rasterizationSamples = samples, - .sampleShadingEnable = false, - .pSampleMask = (VkSampleMask[]) { ~0 }, - .alphaToCoverageEnable = false, - .alphaToOneEnable = false, - }, - .pDepthStencilState = ds_state, - .pColorBlendState = cb_state, - .pDynamicState = &(VkPipelineDynamicStateCreateInfo) { - /* The meta clear pipeline declares all state as dynamic. - * As a consequence, vkCmdBindPipeline writes no dynamic state - * to the cmd buffer. Therefore, at the end of the meta clear, - * we need only restore dynamic state was vkCmdSet. - */ - .sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO, - .dynamicStateCount = 8, - .pDynamicStates = (VkDynamicState[]) { - /* Everything except stencil write mask */ - VK_DYNAMIC_STATE_VIEWPORT, - VK_DYNAMIC_STATE_SCISSOR, - VK_DYNAMIC_STATE_LINE_WIDTH, - VK_DYNAMIC_STATE_DEPTH_BIAS, - VK_DYNAMIC_STATE_BLEND_CONSTANTS, - VK_DYNAMIC_STATE_DEPTH_BOUNDS, - VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK, - VK_DYNAMIC_STATE_STENCIL_REFERENCE, - }, - }, - .flags = 0, - .renderPass = anv_render_pass_to_handle(&anv_meta_dummy_renderpass), - .subpass = 0, - }, - &(struct anv_graphics_pipeline_create_info) { - .color_attachment_count = MAX_RTS, - .use_repclear = use_repclear, - .disable_vs = true, - .use_rectlist = true - }, - alloc, - &pipeline_h); - - ralloc_free(vs_nir); - ralloc_free(fs_nir); - - *pipeline = anv_pipeline_from_handle(pipeline_h); - - return result; -} - -static VkResult -create_color_pipeline(struct anv_device *device, - uint32_t samples, - uint32_t frag_output, - struct anv_pipeline **pipeline) -{ - struct nir_shader *vs_nir; - struct nir_shader *fs_nir; - build_color_shaders(&vs_nir, &fs_nir, frag_output); - - const VkPipelineVertexInputStateCreateInfo vi_state = { - .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, - .vertexBindingDescriptionCount = 1, - .pVertexBindingDescriptions = (VkVertexInputBindingDescription[]) { - { - .binding = 0, - .stride = sizeof(struct color_clear_vattrs), - .inputRate = VK_VERTEX_INPUT_RATE_VERTEX - }, - }, - .vertexAttributeDescriptionCount = 3, - .pVertexAttributeDescriptions = (VkVertexInputAttributeDescription[]) { - { - /* VUE Header */ - .location = 0, - .binding = 0, - .format = VK_FORMAT_R32G32B32A32_UINT, - .offset = offsetof(struct color_clear_vattrs, vue_header), - }, - { - /* Position */ - .location = 1, - .binding = 0, - .format = VK_FORMAT_R32G32_SFLOAT, - .offset = offsetof(struct color_clear_vattrs, position), - }, - { - /* Color */ - .location = 2, - .binding = 0, - .format = VK_FORMAT_R32G32B32A32_SFLOAT, - .offset = offsetof(struct color_clear_vattrs, color), - }, - }, - }; - - const VkPipelineDepthStencilStateCreateInfo ds_state = { - .sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, - .depthTestEnable = false, - .depthWriteEnable = false, - .depthBoundsTestEnable = false, - .stencilTestEnable = false, - }; - - VkPipelineColorBlendAttachmentState blend_attachment_state[MAX_RTS] = { 0 }; - blend_attachment_state[frag_output] = (VkPipelineColorBlendAttachmentState) { - .blendEnable = false, - .colorWriteMask = VK_COLOR_COMPONENT_A_BIT | - VK_COLOR_COMPONENT_R_BIT | - VK_COLOR_COMPONENT_G_BIT | - VK_COLOR_COMPONENT_B_BIT, - }; - - const VkPipelineColorBlendStateCreateInfo cb_state = { - .sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, - .logicOpEnable = false, - .attachmentCount = MAX_RTS, - .pAttachments = blend_attachment_state - }; - - /* Use the repclear shader. Since the NIR shader we are providing has - * exactly one output, that output will get compacted down to binding - * table entry 0. The hard-coded repclear shader is then exactly what - * we want regardless of what attachment we are actually clearing. - */ - return - create_pipeline(device, samples, vs_nir, fs_nir, &vi_state, &ds_state, - &cb_state, &device->meta_state.alloc, - /*use_repclear*/ true, pipeline); -} - -static void -destroy_pipeline(struct anv_device *device, struct anv_pipeline *pipeline) -{ - if (!pipeline) - return; - - ANV_CALL(DestroyPipeline)(anv_device_to_handle(device), - anv_pipeline_to_handle(pipeline), - &device->meta_state.alloc); -} - -void -anv_device_finish_meta_clear_state(struct anv_device *device) -{ - struct anv_meta_state *state = &device->meta_state; - - for (uint32_t i = 0; i < ARRAY_SIZE(state->clear); ++i) { - for (uint32_t j = 0; j < ARRAY_SIZE(state->clear[i].color_pipelines); ++j) { - destroy_pipeline(device, state->clear[i].color_pipelines[j]); - } - - destroy_pipeline(device, state->clear[i].depth_only_pipeline); - destroy_pipeline(device, state->clear[i].stencil_only_pipeline); - destroy_pipeline(device, state->clear[i].depthstencil_pipeline); - } -} - -static void -build_depthstencil_shader(struct nir_shader **out_vs) -{ - nir_builder vs_b; - - nir_builder_init_simple_shader(&vs_b, NULL, MESA_SHADER_VERTEX, NULL); - - vs_b.shader->info.name = ralloc_strdup(vs_b.shader, "meta_clear_depthstencil_vs"); - - const struct glsl_type *position_type = glsl_vec4_type(); - - nir_variable *vs_in_pos = - nir_variable_create(vs_b.shader, nir_var_shader_in, position_type, - "a_position"); - vs_in_pos->data.location = VERT_ATTRIB_GENERIC0; - - nir_variable *vs_out_pos = - nir_variable_create(vs_b.shader, nir_var_shader_out, position_type, - "gl_Position"); - vs_out_pos->data.location = VARYING_SLOT_POS; - - nir_copy_var(&vs_b, vs_out_pos, vs_in_pos); - - *out_vs = vs_b.shader; -} - -static VkResult -create_depthstencil_pipeline(struct anv_device *device, - VkImageAspectFlags aspects, - uint32_t samples, - struct anv_pipeline **pipeline) -{ - struct nir_shader *vs_nir; - - build_depthstencil_shader(&vs_nir); - - const VkPipelineVertexInputStateCreateInfo vi_state = { - .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, - .vertexBindingDescriptionCount = 1, - .pVertexBindingDescriptions = (VkVertexInputBindingDescription[]) { - { - .binding = 0, - .stride = sizeof(struct depthstencil_clear_vattrs), - .inputRate = VK_VERTEX_INPUT_RATE_VERTEX - }, - }, - .vertexAttributeDescriptionCount = 2, - .pVertexAttributeDescriptions = (VkVertexInputAttributeDescription[]) { - { - /* VUE Header */ - .location = 0, - .binding = 0, - .format = VK_FORMAT_R32G32B32A32_UINT, - .offset = offsetof(struct depthstencil_clear_vattrs, vue_header), - }, - { - /* Position */ - .location = 1, - .binding = 0, - .format = VK_FORMAT_R32G32_SFLOAT, - .offset = offsetof(struct depthstencil_clear_vattrs, position), - }, - }, - }; - - const VkPipelineDepthStencilStateCreateInfo ds_state = { - .sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, - .depthTestEnable = (aspects & VK_IMAGE_ASPECT_DEPTH_BIT), - .depthCompareOp = VK_COMPARE_OP_ALWAYS, - .depthWriteEnable = (aspects & VK_IMAGE_ASPECT_DEPTH_BIT), - .depthBoundsTestEnable = false, - .stencilTestEnable = (aspects & VK_IMAGE_ASPECT_STENCIL_BIT), - .front = { - .passOp = VK_STENCIL_OP_REPLACE, - .compareOp = VK_COMPARE_OP_ALWAYS, - .writeMask = UINT32_MAX, - .reference = 0, /* dynamic */ - }, - .back = { 0 /* dont care */ }, - }; - - const VkPipelineColorBlendStateCreateInfo cb_state = { - .sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, - .logicOpEnable = false, - .attachmentCount = 0, - .pAttachments = NULL, - }; - - return create_pipeline(device, samples, vs_nir, NULL, &vi_state, &ds_state, - &cb_state, &device->meta_state.alloc, - /*use_repclear*/ true, pipeline); -} - -VkResult -anv_device_init_meta_clear_state(struct anv_device *device) -{ - VkResult res; - struct anv_meta_state *state = &device->meta_state; - - zero(device->meta_state.clear); - - for (uint32_t i = 0; i < ARRAY_SIZE(state->clear); ++i) { - uint32_t samples = 1 << i; - - for (uint32_t j = 0; j < ARRAY_SIZE(state->clear[i].color_pipelines); ++j) { - res = create_color_pipeline(device, samples, /* frag_output */ j, - &state->clear[i].color_pipelines[j]); - if (res != VK_SUCCESS) - goto fail; - } - - res = create_depthstencil_pipeline(device, - VK_IMAGE_ASPECT_DEPTH_BIT, samples, - &state->clear[i].depth_only_pipeline); - if (res != VK_SUCCESS) - goto fail; - - res = create_depthstencil_pipeline(device, - VK_IMAGE_ASPECT_STENCIL_BIT, samples, - &state->clear[i].stencil_only_pipeline); - if (res != VK_SUCCESS) - goto fail; - - res = create_depthstencil_pipeline(device, - VK_IMAGE_ASPECT_DEPTH_BIT | - VK_IMAGE_ASPECT_STENCIL_BIT, samples, - &state->clear[i].depthstencil_pipeline); - if (res != VK_SUCCESS) - goto fail; - } - - return VK_SUCCESS; - -fail: - anv_device_finish_meta_clear_state(device); - return res; -} diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c index 6b393a67bfc..672f73d191c 100644 --- a/src/intel/vulkan/anv_pipeline.c +++ b/src/intel/vulkan/anv_pipeline.c @@ -960,10 +960,8 @@ anv_pipeline_validate_create_info(const VkGraphicsPipelineCreateInfo *info) renderpass = anv_render_pass_from_handle(info->renderPass); assert(renderpass); - if (renderpass != &anv_meta_dummy_renderpass) { - assert(info->subpass < renderpass->subpass_count); - subpass = &renderpass->subpasses[info->subpass]; - } + assert(info->subpass < renderpass->subpass_count); + subpass = &renderpass->subpasses[info->subpass]; assert(info->stageCount >= 1); assert(info->pVertexInputState); diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 3f82196d663..7a963c8fb69 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -590,69 +590,6 @@ struct anv_instance { VkResult anv_init_wsi(struct anv_physical_device *physical_device); void anv_finish_wsi(struct anv_physical_device *physical_device); -struct anv_meta_state { - VkAllocationCallbacks alloc; - - /** - * Use array element `i` for images with `2^i` samples. - */ - struct { - /** - * Pipeline N is used to clear color attachment N of the current - * subpass. - * - * HACK: We use one pipeline per color attachment to work around the - * compiler's inability to dynamically set the render target index of - * the render target write message. - */ - struct anv_pipeline *color_pipelines[MAX_RTS]; - - struct anv_pipeline *depth_only_pipeline; - struct anv_pipeline *stencil_only_pipeline; - struct anv_pipeline *depthstencil_pipeline; - } clear[1 + MAX_SAMPLES_LOG2]; - - struct { - VkRenderPass render_pass; - - /** Pipeline that blits from a 1D image. */ - VkPipeline pipeline_1d_src; - - /** Pipeline that blits from a 2D image. */ - VkPipeline pipeline_2d_src; - - /** Pipeline that blits from a 3D image. */ - VkPipeline pipeline_3d_src; - - VkPipelineLayout pipeline_layout; - VkDescriptorSetLayout ds_layout; - } blit; - - struct { - VkRenderPass render_pass; - - VkPipelineLayout img_p_layout; - VkDescriptorSetLayout img_ds_layout; - VkPipelineLayout buf_p_layout; - VkDescriptorSetLayout buf_ds_layout; - - /* Pipelines indexed by source and destination type. See the - * blit2d_src_type and blit2d_dst_type enums in anv_meta_blit2d.c to - * see what these mean. - */ - VkPipeline pipelines[2][3]; - } blit2d; - - struct { - /** Pipeline [i] resolves an image with 2^(i+1) samples. */ - VkPipeline pipelines[MAX_SAMPLES_LOG2]; - - VkRenderPass pass; - VkPipelineLayout pipeline_layout; - VkDescriptorSetLayout ds_layout; - } resolve; -}; - struct anv_queue { VK_LOADER_DATA _loader_data; @@ -712,8 +649,6 @@ struct anv_device { struct anv_bo workaround_bo; - struct anv_meta_state meta_state; - struct anv_pipeline_cache blorp_shader_cache; struct blorp_context blorp; @@ -1883,8 +1818,6 @@ struct anv_render_pass { struct anv_subpass subpasses[0]; }; -extern struct anv_render_pass anv_meta_dummy_renderpass; - struct anv_query_pool_slot { uint64_t begin; uint64_t end; @@ -1897,9 +1830,6 @@ struct anv_query_pool { struct anv_bo bo; }; -VkResult anv_device_init_meta(struct anv_device *device); -void anv_device_finish_meta(struct anv_device *device); - void *anv_lookup_entrypoint(const char *name); void anv_dump_image_to_ppm(struct anv_device *device, |