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#ifndef PVR_HARDCODE_SHADERS_H 25bf215546Sopenharmony_ci#define PVR_HARDCODE_SHADERS_H 26bf215546Sopenharmony_ci 27bf215546Sopenharmony_ci#include <stdbool.h> 28bf215546Sopenharmony_ci#include <stdint.h> 29bf215546Sopenharmony_ci#include <vulkan/vulkan_core.h> 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_ci#include "compiler/shader_enums.h" 32bf215546Sopenharmony_ci#include "rogue/rogue_build_data.h" 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_ci/** 35bf215546Sopenharmony_ci * \file pvr_hardcode.h 36bf215546Sopenharmony_ci * 37bf215546Sopenharmony_ci * \brief Contains hard coding functions. 38bf215546Sopenharmony_ci * This should eventually be deleted as the compiler becomes more capable. 39bf215546Sopenharmony_ci */ 40bf215546Sopenharmony_ci 41bf215546Sopenharmony_cistruct pvr_compute_pipeline_shader_state; 42bf215546Sopenharmony_cistruct pvr_device; 43bf215546Sopenharmony_cistruct pvr_fragment_shader_state; 44bf215546Sopenharmony_cistruct pvr_hard_coding_data; 45bf215546Sopenharmony_cistruct pvr_vertex_shader_state; 46bf215546Sopenharmony_ci 47bf215546Sopenharmony_cistruct pvr_explicit_constant_usage { 48bf215546Sopenharmony_ci /* Hardware register number assigned to the explicit constant with the lower 49bf215546Sopenharmony_ci * pre_assigned offset. 50bf215546Sopenharmony_ci */ 51bf215546Sopenharmony_ci uint32_t start_offset; 52bf215546Sopenharmony_ci}; 53bf215546Sopenharmony_ci 54bf215546Sopenharmony_cistruct pvr_hard_code_compute_build_info { 55bf215546Sopenharmony_ci struct rogue_ubo_data ubo_data; 56bf215546Sopenharmony_ci struct rogue_compile_time_consts_data compile_time_consts_data; 57bf215546Sopenharmony_ci 58bf215546Sopenharmony_ci uint32_t local_invocation_regs[2]; 59bf215546Sopenharmony_ci uint32_t work_group_regs[3]; 60bf215546Sopenharmony_ci uint32_t barrier_reg; 61bf215546Sopenharmony_ci uint32_t usc_temps; 62bf215546Sopenharmony_ci 63bf215546Sopenharmony_ci struct pvr_explicit_constant_usage explicit_conts_usage; 64bf215546Sopenharmony_ci}; 65bf215546Sopenharmony_ci 66bf215546Sopenharmony_cistruct pvr_hard_code_graphics_build_info { 67bf215546Sopenharmony_ci struct rogue_build_data stage_data; 68bf215546Sopenharmony_ci 69bf215546Sopenharmony_ci struct rogue_common_build_data vert_common_data; 70bf215546Sopenharmony_ci struct rogue_common_build_data frag_common_data; 71bf215546Sopenharmony_ci 72bf215546Sopenharmony_ci struct pvr_explicit_constant_usage vert_explicit_conts_usage; 73bf215546Sopenharmony_ci struct pvr_explicit_constant_usage frag_explicit_conts_usage; 74bf215546Sopenharmony_ci}; 75bf215546Sopenharmony_ci 76bf215546Sopenharmony_ci/* Returns true if the shader for the currently running program requires hard 77bf215546Sopenharmony_ci * coded shaders. 78bf215546Sopenharmony_ci */ 79bf215546Sopenharmony_cibool pvr_hard_code_shader_required(const struct pvr_device_info *const dev_info); 80bf215546Sopenharmony_ci 81bf215546Sopenharmony_ciVkResult pvr_hard_code_compute_pipeline( 82bf215546Sopenharmony_ci struct pvr_device *const device, 83bf215546Sopenharmony_ci struct pvr_compute_pipeline_shader_state *const shader_state_out, 84bf215546Sopenharmony_ci struct pvr_hard_code_compute_build_info *const build_info_out); 85bf215546Sopenharmony_ci 86bf215546Sopenharmony_ci/* Returns a mask of MESA_SHADER_* (gl_shader_stage) indicating which stage 87bf215546Sopenharmony_ci * needs to be hard coded. 88bf215546Sopenharmony_ci */ 89bf215546Sopenharmony_ciuint32_t 90bf215546Sopenharmony_cipvr_hard_code_graphics_get_flags(const struct pvr_device_info *const dev_info); 91bf215546Sopenharmony_ci 92bf215546Sopenharmony_ci/* pipeline_n: 93bf215546Sopenharmony_ci * The pipeline number. Each pipeline created requires unique hard 94bf215546Sopenharmony_ci * coding so a pipeline number is necessary to identify which data to use. 95bf215546Sopenharmony_ci * This pipeline number to request data for the first pipeline to be created 96bf215546Sopenharmony_ci * is 0 and should be incremented for each subsequent pipeline. 97bf215546Sopenharmony_ci */ 98bf215546Sopenharmony_civoid pvr_hard_code_graphics_shader( 99bf215546Sopenharmony_ci const struct pvr_device_info *const dev_info, 100bf215546Sopenharmony_ci uint32_t pipeline_n, 101bf215546Sopenharmony_ci gl_shader_stage stage, 102bf215546Sopenharmony_ci struct rogue_shader_binary **const shader_out); 103bf215546Sopenharmony_ci 104bf215546Sopenharmony_civoid pvr_hard_code_graphics_vertex_state( 105bf215546Sopenharmony_ci const struct pvr_device_info *const dev_info, 106bf215546Sopenharmony_ci uint32_t pipeline_n, 107bf215546Sopenharmony_ci struct pvr_vertex_shader_state *const vert_state_out); 108bf215546Sopenharmony_ci 109bf215546Sopenharmony_civoid pvr_hard_code_graphics_fragment_state( 110bf215546Sopenharmony_ci const struct pvr_device_info *const dev_info, 111bf215546Sopenharmony_ci uint32_t pipeline_n, 112bf215546Sopenharmony_ci struct pvr_fragment_shader_state *const frag_state_out); 113bf215546Sopenharmony_ci 114bf215546Sopenharmony_civoid pvr_hard_code_graphics_get_build_info( 115bf215546Sopenharmony_ci const struct pvr_device_info *const dev_info, 116bf215546Sopenharmony_ci uint32_t pipeline_n, 117bf215546Sopenharmony_ci gl_shader_stage stage, 118bf215546Sopenharmony_ci struct rogue_common_build_data *const common_build_data, 119bf215546Sopenharmony_ci struct rogue_build_data *const build_data, 120bf215546Sopenharmony_ci struct pvr_explicit_constant_usage *const explicit_const_usage); 121bf215546Sopenharmony_ci 122bf215546Sopenharmony_civoid pvr_hard_code_get_idfwdf_program( 123bf215546Sopenharmony_ci const struct pvr_device_info *const dev_info, 124bf215546Sopenharmony_ci const struct rogue_shader_binary **const program_out, 125bf215546Sopenharmony_ci uint32_t *usc_shareds_out, 126bf215546Sopenharmony_ci uint32_t *usc_temps_out); 127bf215546Sopenharmony_ci 128bf215546Sopenharmony_ci#endif /* PVR_HARDCODE_SHADERS_H */ 129