1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2022 Imagination Technologies Ltd. 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy 5bf215546Sopenharmony_ci * of this software and associated documentation files (the "Software"), to deal 6bf215546Sopenharmony_ci * in the Software without restriction, including without limitation the rights 7bf215546Sopenharmony_ci * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8bf215546Sopenharmony_ci * copies of the Software, and to permit persons to whom the Software is 9bf215546Sopenharmony_ci * furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18bf215546Sopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20bf215546Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21bf215546Sopenharmony_ci * SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#include <stdbool.h> 25bf215546Sopenharmony_ci 26bf215546Sopenharmony_ci#include "pvr_hw_pass.h" 27bf215546Sopenharmony_ci#include "pvr_private.h" 28bf215546Sopenharmony_ci#include "vk_alloc.h" 29bf215546Sopenharmony_ci 30bf215546Sopenharmony_civoid pvr_destroy_renderpass_hwsetup(struct pvr_device *device, 31bf215546Sopenharmony_ci struct pvr_renderpass_hwsetup *hw_setup) 32bf215546Sopenharmony_ci{ 33bf215546Sopenharmony_ci vk_free(&device->vk.alloc, hw_setup); 34bf215546Sopenharmony_ci} 35bf215546Sopenharmony_ci 36bf215546Sopenharmony_cistruct pvr_renderpass_hwsetup * 37bf215546Sopenharmony_cipvr_create_renderpass_hwsetup(struct pvr_device *device, 38bf215546Sopenharmony_ci struct pvr_render_pass *pass, 39bf215546Sopenharmony_ci bool disable_merge) 40bf215546Sopenharmony_ci{ 41bf215546Sopenharmony_ci struct pvr_renderpass_hwsetup_eot_surface *eot_surface; 42bf215546Sopenharmony_ci enum pvr_renderpass_surface_initop *color_initops; 43bf215546Sopenharmony_ci struct pvr_renderpass_hwsetup_subpass *subpasses; 44bf215546Sopenharmony_ci struct pvr_renderpass_hwsetup_render *renders; 45bf215546Sopenharmony_ci struct pvr_renderpass_colorinit *color_inits; 46bf215546Sopenharmony_ci struct pvr_renderpass_hwsetup *hw_setup; 47bf215546Sopenharmony_ci struct pvr_renderpass_hw_map *subpass_map; 48bf215546Sopenharmony_ci struct usc_mrt_resource *mrt_resources; 49bf215546Sopenharmony_ci 50bf215546Sopenharmony_ci VK_MULTIALLOC(ma); 51bf215546Sopenharmony_ci vk_multialloc_add(&ma, &hw_setup, __typeof__(*hw_setup), 1); 52bf215546Sopenharmony_ci vk_multialloc_add(&ma, &renders, __typeof__(*renders), 1); 53bf215546Sopenharmony_ci vk_multialloc_add(&ma, &color_inits, __typeof__(*color_inits), 1); 54bf215546Sopenharmony_ci vk_multialloc_add(&ma, &subpass_map, __typeof__(*subpass_map), 1); 55bf215546Sopenharmony_ci vk_multialloc_add(&ma, &mrt_resources, __typeof__(*mrt_resources), 2); 56bf215546Sopenharmony_ci vk_multialloc_add(&ma, &subpasses, __typeof__(*subpasses), 1); 57bf215546Sopenharmony_ci vk_multialloc_add(&ma, &eot_surface, __typeof__(*eot_surface), 1); 58bf215546Sopenharmony_ci vk_multialloc_add(&ma, 59bf215546Sopenharmony_ci &color_initops, 60bf215546Sopenharmony_ci __typeof__(*color_initops), 61bf215546Sopenharmony_ci pass->subpasses[0].color_count); 62bf215546Sopenharmony_ci /* Note, no more multialloc slots available (maximum supported is 8). */ 63bf215546Sopenharmony_ci 64bf215546Sopenharmony_ci if (!vk_multialloc_zalloc(&ma, 65bf215546Sopenharmony_ci &device->vk.alloc, 66bf215546Sopenharmony_ci VK_SYSTEM_ALLOCATION_SCOPE_DEVICE)) { 67bf215546Sopenharmony_ci return NULL; 68bf215546Sopenharmony_ci } 69bf215546Sopenharmony_ci 70bf215546Sopenharmony_ci /* FIXME: Remove hardcoding of hw_setup structure. */ 71bf215546Sopenharmony_ci subpasses[0].z_replicate = -1; 72bf215546Sopenharmony_ci subpasses[0].depth_initop = RENDERPASS_SURFACE_INITOP_CLEAR; 73bf215546Sopenharmony_ci subpasses[0].stencil_clear = false; 74bf215546Sopenharmony_ci subpasses[0].driver_id = 0; 75bf215546Sopenharmony_ci color_initops[0] = RENDERPASS_SURFACE_INITOP_NOP; 76bf215546Sopenharmony_ci subpasses[0].color_initops = color_initops; 77bf215546Sopenharmony_ci subpasses[0].client_data = NULL; 78bf215546Sopenharmony_ci renders[0].subpass_count = 1; 79bf215546Sopenharmony_ci renders[0].subpasses = subpasses; 80bf215546Sopenharmony_ci 81bf215546Sopenharmony_ci renders[0].sample_count = 1; 82bf215546Sopenharmony_ci renders[0].ds_surface_id = 1; 83bf215546Sopenharmony_ci renders[0].depth_init = RENDERPASS_SURFACE_INITOP_CLEAR; 84bf215546Sopenharmony_ci renders[0].stencil_init = RENDERPASS_SURFACE_INITOP_NOP; 85bf215546Sopenharmony_ci 86bf215546Sopenharmony_ci mrt_resources[0].type = USC_MRT_RESOURCE_TYPE_OUTPUT_REGISTER; 87bf215546Sopenharmony_ci mrt_resources[0].u.reg.out_reg = 0; 88bf215546Sopenharmony_ci mrt_resources[0].u.reg.offset = 0; 89bf215546Sopenharmony_ci renders[0].init_setup.render_targets_count = 1; 90bf215546Sopenharmony_ci renders[0].init_setup.mrt_resources = &mrt_resources[0]; 91bf215546Sopenharmony_ci 92bf215546Sopenharmony_ci color_inits[0].op = RENDERPASS_SURFACE_INITOP_CLEAR; 93bf215546Sopenharmony_ci color_inits[0].driver_id = 0; 94bf215546Sopenharmony_ci renders[0].color_init_count = 1; 95bf215546Sopenharmony_ci renders[0].color_init = color_inits; 96bf215546Sopenharmony_ci 97bf215546Sopenharmony_ci mrt_resources[1].type = USC_MRT_RESOURCE_TYPE_OUTPUT_REGISTER; 98bf215546Sopenharmony_ci mrt_resources[1].u.reg.out_reg = 0; 99bf215546Sopenharmony_ci mrt_resources[1].u.reg.offset = 0; 100bf215546Sopenharmony_ci renders[0].eot_setup.render_targets_count = 1; 101bf215546Sopenharmony_ci renders[0].eot_setup.mrt_resources = &mrt_resources[1]; 102bf215546Sopenharmony_ci 103bf215546Sopenharmony_ci eot_surface->mrt_index = 0; 104bf215546Sopenharmony_ci eot_surface->attachment_index = 0; 105bf215546Sopenharmony_ci eot_surface->need_resolve = false; 106bf215546Sopenharmony_ci eot_surface->resolve_type = PVR_RESOLVE_TYPE_INVALID; 107bf215546Sopenharmony_ci eot_surface->src_attachment_index = 0; 108bf215546Sopenharmony_ci renders[0].eot_surfaces = eot_surface; 109bf215546Sopenharmony_ci renders[0].eot_surface_count = 1; 110bf215546Sopenharmony_ci 111bf215546Sopenharmony_ci renders[0].output_regs_count = 1; 112bf215546Sopenharmony_ci renders[0].tile_buffers_count = 0; 113bf215546Sopenharmony_ci renders[0].client_data = NULL; 114bf215546Sopenharmony_ci hw_setup->render_count = 1; 115bf215546Sopenharmony_ci hw_setup->renders = renders; 116bf215546Sopenharmony_ci 117bf215546Sopenharmony_ci subpass_map->render = 0; 118bf215546Sopenharmony_ci subpass_map->subpass = 0; 119bf215546Sopenharmony_ci hw_setup->subpass_map = subpass_map; 120bf215546Sopenharmony_ci 121bf215546Sopenharmony_ci return hw_setup; 122bf215546Sopenharmony_ci} 123