1*61046927SAndroid Build Coastguard Worker /* 2*61046927SAndroid Build Coastguard Worker * Copyright © 2022 Imagination Technologies Ltd. 3*61046927SAndroid Build Coastguard Worker * 4*61046927SAndroid Build Coastguard Worker * Permission is hereby granted, free of charge, to any person obtaining a copy 5*61046927SAndroid Build Coastguard Worker * of this software and associated documentation files (the "Software"), to deal 6*61046927SAndroid Build Coastguard Worker * in the Software without restriction, including without limitation the rights 7*61046927SAndroid Build Coastguard Worker * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8*61046927SAndroid Build Coastguard Worker * copies of the Software, and to permit persons to whom the Software is 9*61046927SAndroid Build Coastguard Worker * furnished to do so, subject to the following conditions: 10*61046927SAndroid Build Coastguard Worker * 11*61046927SAndroid Build Coastguard Worker * The above copyright notice and this permission notice (including the next 12*61046927SAndroid Build Coastguard Worker * paragraph) shall be included in all copies or substantial portions of the 13*61046927SAndroid Build Coastguard Worker * Software. 14*61046927SAndroid Build Coastguard Worker * 15*61046927SAndroid Build Coastguard Worker * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16*61046927SAndroid Build Coastguard Worker * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17*61046927SAndroid Build Coastguard Worker * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18*61046927SAndroid Build Coastguard Worker * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19*61046927SAndroid Build Coastguard Worker * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20*61046927SAndroid Build Coastguard Worker * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21*61046927SAndroid Build Coastguard Worker * SOFTWARE. 22*61046927SAndroid Build Coastguard Worker */ 23*61046927SAndroid Build Coastguard Worker 24*61046927SAndroid Build Coastguard Worker #ifndef PVR_HARDCODE_SHADERS_H 25*61046927SAndroid Build Coastguard Worker #define PVR_HARDCODE_SHADERS_H 26*61046927SAndroid Build Coastguard Worker 27*61046927SAndroid Build Coastguard Worker #include <stdbool.h> 28*61046927SAndroid Build Coastguard Worker #include <stdint.h> 29*61046927SAndroid Build Coastguard Worker #include <vulkan/vulkan_core.h> 30*61046927SAndroid Build Coastguard Worker 31*61046927SAndroid Build Coastguard Worker #include "compiler/shader_enums.h" 32*61046927SAndroid Build Coastguard Worker #include "rogue/rogue.h" 33*61046927SAndroid Build Coastguard Worker #include "util/u_dynarray.h" 34*61046927SAndroid Build Coastguard Worker 35*61046927SAndroid Build Coastguard Worker /** 36*61046927SAndroid Build Coastguard Worker * \file pvr_hardcode.h 37*61046927SAndroid Build Coastguard Worker * 38*61046927SAndroid Build Coastguard Worker * \brief Contains hard coding functions. 39*61046927SAndroid Build Coastguard Worker * This should eventually be deleted as the compiler becomes more capable. 40*61046927SAndroid Build Coastguard Worker */ 41*61046927SAndroid Build Coastguard Worker 42*61046927SAndroid Build Coastguard Worker struct pvr_compute_shader_state; 43*61046927SAndroid Build Coastguard Worker struct pvr_device; 44*61046927SAndroid Build Coastguard Worker struct pvr_fragment_shader_state; 45*61046927SAndroid Build Coastguard Worker struct pvr_hard_coding_data; 46*61046927SAndroid Build Coastguard Worker struct pvr_vertex_shader_state; 47*61046927SAndroid Build Coastguard Worker 48*61046927SAndroid Build Coastguard Worker struct pvr_explicit_constant_usage { 49*61046927SAndroid Build Coastguard Worker /* Hardware register number assigned to the explicit constant with the lower 50*61046927SAndroid Build Coastguard Worker * pre_assigned offset. 51*61046927SAndroid Build Coastguard Worker */ 52*61046927SAndroid Build Coastguard Worker uint32_t start_offset; 53*61046927SAndroid Build Coastguard Worker }; 54*61046927SAndroid Build Coastguard Worker 55*61046927SAndroid Build Coastguard Worker struct pvr_hard_code_compute_build_info { 56*61046927SAndroid Build Coastguard Worker rogue_ubo_data ubo_data; 57*61046927SAndroid Build Coastguard Worker rogue_compile_time_consts_data compile_time_consts_data; 58*61046927SAndroid Build Coastguard Worker 59*61046927SAndroid Build Coastguard Worker uint32_t local_invocation_regs[2]; 60*61046927SAndroid Build Coastguard Worker uint32_t work_group_regs[3]; 61*61046927SAndroid Build Coastguard Worker uint32_t barrier_reg; 62*61046927SAndroid Build Coastguard Worker uint32_t usc_temps; 63*61046927SAndroid Build Coastguard Worker 64*61046927SAndroid Build Coastguard Worker struct pvr_explicit_constant_usage explicit_conts_usage; 65*61046927SAndroid Build Coastguard Worker }; 66*61046927SAndroid Build Coastguard Worker 67*61046927SAndroid Build Coastguard Worker struct pvr_hard_code_graphics_build_info { 68*61046927SAndroid Build Coastguard Worker rogue_build_data stage_data; 69*61046927SAndroid Build Coastguard Worker 70*61046927SAndroid Build Coastguard Worker rogue_common_build_data vert_common_data; 71*61046927SAndroid Build Coastguard Worker rogue_common_build_data frag_common_data; 72*61046927SAndroid Build Coastguard Worker 73*61046927SAndroid Build Coastguard Worker struct pvr_explicit_constant_usage vert_explicit_conts_usage; 74*61046927SAndroid Build Coastguard Worker struct pvr_explicit_constant_usage frag_explicit_conts_usage; 75*61046927SAndroid Build Coastguard Worker }; 76*61046927SAndroid Build Coastguard Worker 77*61046927SAndroid Build Coastguard Worker /* Returns true if the shader for the currently running program has a hard coded 78*61046927SAndroid Build Coastguard Worker * shader. 79*61046927SAndroid Build Coastguard Worker */ 80*61046927SAndroid Build Coastguard Worker bool pvr_has_hard_coded_shaders(const struct pvr_device_info *const dev_info); 81*61046927SAndroid Build Coastguard Worker 82*61046927SAndroid Build Coastguard Worker VkResult pvr_hard_code_compute_pipeline( 83*61046927SAndroid Build Coastguard Worker struct pvr_device *const device, 84*61046927SAndroid Build Coastguard Worker struct pvr_compute_shader_state *const shader_state_out, 85*61046927SAndroid Build Coastguard Worker struct pvr_hard_code_compute_build_info *const build_info_out); 86*61046927SAndroid Build Coastguard Worker 87*61046927SAndroid Build Coastguard Worker /* Returns a mask of MESA_SHADER_* (gl_shader_stage) indicating which stage 88*61046927SAndroid Build Coastguard Worker * needs to be hard coded. 89*61046927SAndroid Build Coastguard Worker */ 90*61046927SAndroid Build Coastguard Worker uint32_t 91*61046927SAndroid Build Coastguard Worker pvr_hard_code_graphics_get_flags(const struct pvr_device_info *const dev_info); 92*61046927SAndroid Build Coastguard Worker 93*61046927SAndroid Build Coastguard Worker /* pipeline_n: 94*61046927SAndroid Build Coastguard Worker * The pipeline number. Each pipeline created requires unique hard 95*61046927SAndroid Build Coastguard Worker * coding so a pipeline number is necessary to identify which data to use. 96*61046927SAndroid Build Coastguard Worker * This pipeline number to request data for the first pipeline to be created 97*61046927SAndroid Build Coastguard Worker * is 0 and should be incremented for each subsequent pipeline. 98*61046927SAndroid Build Coastguard Worker */ 99*61046927SAndroid Build Coastguard Worker void pvr_hard_code_graphics_shader(const struct pvr_device_info *const dev_info, 100*61046927SAndroid Build Coastguard Worker uint32_t pipeline_n, 101*61046927SAndroid Build Coastguard Worker gl_shader_stage stage, 102*61046927SAndroid Build Coastguard Worker struct util_dynarray *shader_out); 103*61046927SAndroid Build Coastguard Worker 104*61046927SAndroid Build Coastguard Worker void pvr_hard_code_graphics_vertex_state( 105*61046927SAndroid Build Coastguard Worker const struct pvr_device_info *const dev_info, 106*61046927SAndroid Build Coastguard Worker uint32_t pipeline_n, 107*61046927SAndroid Build Coastguard Worker struct pvr_vertex_shader_state *const vert_state_out); 108*61046927SAndroid Build Coastguard Worker 109*61046927SAndroid Build Coastguard Worker void pvr_hard_code_graphics_fragment_state( 110*61046927SAndroid Build Coastguard Worker const struct pvr_device_info *const dev_info, 111*61046927SAndroid Build Coastguard Worker uint32_t pipeline_n, 112*61046927SAndroid Build Coastguard Worker struct pvr_fragment_shader_state *const frag_state_out); 113*61046927SAndroid Build Coastguard Worker 114*61046927SAndroid Build Coastguard Worker void pvr_hard_code_graphics_get_build_info( 115*61046927SAndroid Build Coastguard Worker const struct pvr_device_info *const dev_info, 116*61046927SAndroid Build Coastguard Worker uint32_t pipeline_n, 117*61046927SAndroid Build Coastguard Worker gl_shader_stage stage, 118*61046927SAndroid Build Coastguard Worker rogue_common_build_data *const common_build_data, 119*61046927SAndroid Build Coastguard Worker rogue_build_data *const build_data, 120*61046927SAndroid Build Coastguard Worker struct pvr_explicit_constant_usage *const explicit_const_usage); 121*61046927SAndroid Build Coastguard Worker 122*61046927SAndroid Build Coastguard Worker void pvr_hard_code_get_idfwdf_program( 123*61046927SAndroid Build Coastguard Worker const struct pvr_device_info *const dev_info, 124*61046927SAndroid Build Coastguard Worker struct util_dynarray *program_out, 125*61046927SAndroid Build Coastguard Worker uint32_t *usc_shareds_out, 126*61046927SAndroid Build Coastguard Worker uint32_t *usc_temps_out); 127*61046927SAndroid Build Coastguard Worker 128*61046927SAndroid Build Coastguard Worker void pvr_hard_code_get_passthrough_vertex_shader( 129*61046927SAndroid Build Coastguard Worker const struct pvr_device_info *const dev_info, 130*61046927SAndroid Build Coastguard Worker struct util_dynarray *program_out); 131*61046927SAndroid Build Coastguard Worker void pvr_hard_code_get_passthrough_rta_vertex_shader( 132*61046927SAndroid Build Coastguard Worker const struct pvr_device_info *const dev_info, 133*61046927SAndroid Build Coastguard Worker struct util_dynarray *program_out); 134*61046927SAndroid Build Coastguard Worker 135*61046927SAndroid Build Coastguard Worker #endif /* PVR_HARDCODE_SHADERS_H */ 136