1 /* 2 * Copyright © 2022 Imagination Technologies Ltd. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a copy 5 * of this software and associated documentation files (the "Software"), to deal 6 * in the Software without restriction, including without limitation the rights 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 * copies of the Software, and to permit persons to whom the Software is 9 * 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 THE 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 * SOFTWARE. 22 */ 23 24 #ifndef PVR_DRAW_INDIRECTELEMENTS_BASE_INSTANCE3_H 25 #define PVR_DRAW_INDIRECTELEMENTS_BASE_INSTANCE3_H 26 27 /* Initially generated from ARB_draw_indirect_elements.pds */ 28 29 static const uint32_t pvr_draw_indirect_elements_base_instance3_code[23] = { 30 0xd0000000, /* LD const[0].64: dst(?) <= mem(?) */ 31 0xd1000000, /* WDF */ 32 0x9000a1a0, /* ADD32 ptemp[0].32 = const[2].32 + temp[6].32 */ 33 0x9000a1e1, /* ADD32 ptemp[1].32 = const[2].32 + temp[7].32 */ 34 0x9130f0e3, /* ADD32 ptemp[3].32 = ptemp[3].32 - ptemp[3].32 */ 35 0x04281820, /* MAD temp[0].64 = (temp[5].32 * const[3].32) + 36 const[4].64 */ 37 0x53083008, /* SFTLP32 temp[8].32 = (temp[1].32 | const[6].32) << 0 38 */ 39 0x50040009, /* SFTLP32 temp[9].32 = temp[0].32 << 0 */ 40 0x04203840, /* MAD temp[0].64 = (temp[4].32 * const[7].32) + 41 const[8].64 */ 42 0x50040004, /* SFTLP32 temp[4].32 = temp[0].32 << 0 */ 43 0x501c180a, /* SFTLP32 temp[10].32 = temp[3].32 << 0 */ 44 0x9121028b, /* ADD32 temp[11].32 = temp[4].32 - const[10].32 */ 45 0x5034300c, /* SFTLP32 temp[12].32 = temp[6].32 << 0 */ 46 0xc8000001, /* BRA if keep 1 ( setc = p0 ) */ 47 0xd1840000, /* LIMM temp[1].32 = 0000 */ 48 0x50242000, /* SFTLP32 temp[0].32 = temp[4].32 << 0 */ 49 0xb1800000, /* CMP P0 = (temp[0].64 = 0000) */ 50 0xd9a80000, /* LIMM ? temp[10].32 = 0000 */ 51 0xd9ac0000, /* LIMM ? temp[11].32 = 0000 */ 52 0xd0800006, /* ST const[12].64: mem(?) <= src(?) */ 53 0xd0000007, /* LD const[14].64: dst(?) <= mem(?) */ 54 0xd1000000, /* WDF */ 55 0xf4024003, /* DOUT doutv = temp[0].64, const[2].32; HALT */ 56 }; 57 58 static const struct pvr_psc_program_output 59 pvr_draw_indirect_elements_base_instance3_program = { 60 pvr_draw_indirect_elements_base_instance3_code, /* code segment */ 61 0, /* constant mappings, zeroed since we use the macros below */ 62 7, /* number of constant mappings */ 63 64 16, /* size of data segment, in dwords, aligned to 4 */ 65 24, /* size of code segment, in dwords, aligned to 4 */ 66 20, /* size of temp segment, in dwords, aligned to 4 */ 67 16, /* size of data segment, in dwords */ 68 23, /* size of code segment, in dwords */ 69 20, /* size of temp segment, in dwords */ 70 NULL /* function pointer to write data segment */ 71 }; 72 73 #define pvr_write_draw_indirect_elements_base_instance3_di_data(buffer, \ 74 addr, \ 75 device) \ 76 do { \ 77 uint64_t data = ((addr) | (0x80000000000ULL) | \ 78 ENABLE_SLC_MCU_CACHE_CONTROLS(device)); \ 79 PVR_PDS_PRINT_DATA("DRAW_INDIRECT_ELEMENTS", data, 0); \ 80 memcpy(buffer + 0, &data, sizeof(data)); \ 81 } while (0) 82 #define pvr_write_draw_indirect_elements_base_instance3_write_vdm(buffer, \ 83 addr) \ 84 do { \ 85 uint64_t data = ((addr) | (0x2050000000000ULL)); \ 86 PVR_PDS_PRINT_DATA("DRAW_INDIRECT_ELEMENTS", data, 0); \ 87 memcpy(buffer + 12, &data, sizeof(data)); \ 88 } while (0) 89 #define pvr_write_draw_indirect_elements_base_instance3_flush_vdm(buffer, \ 90 addr) \ 91 do { \ 92 uint64_t data = ((addr) | (0x3960000000000ULL)); \ 93 PVR_PDS_PRINT_DATA("DRAW_INDIRECT_ELEMENTS", data, 0); \ 94 memcpy(buffer + 14, &data, sizeof(data)); \ 95 } while (0) 96 #define pvr_write_draw_indirect_elements_base_instance3_idx_stride(buffer, \ 97 value) \ 98 do { \ 99 uint32_t data = value; \ 100 PVR_PDS_PRINT_DATA("DRAW_INDIRECT_ELEMENTS", data, 0); \ 101 memcpy(buffer + 3, &data, sizeof(data)); \ 102 } while (0) 103 #define pvr_write_draw_indirect_elements_base_instance3_idx_base(buffer, \ 104 value) \ 105 do { \ 106 uint64_t data = value; \ 107 PVR_PDS_PRINT_DATA("DRAW_INDIRECT_ELEMENTS", data, 0); \ 108 memcpy(buffer + 4, &data, sizeof(data)); \ 109 } while (0) 110 #define pvr_write_draw_indirect_elements_base_instance3_idx_header(buffer, \ 111 value) \ 112 do { \ 113 uint32_t data = value; \ 114 PVR_PDS_PRINT_DATA("DRAW_INDIRECT_ELEMENTS", data, 0); \ 115 memcpy(buffer + 6, &data, sizeof(data)); \ 116 } while (0) 117 #define pvr_write_draw_indirect_elements_base_instance3_num_views(buffer, \ 118 value) \ 119 do { \ 120 uint32_t data = value; \ 121 PVR_PDS_PRINT_DATA("DRAW_INDIRECT_ELEMENTS", data, 0); \ 122 memcpy(buffer + 7, &data, sizeof(data)); \ 123 } while (0) 124 #define pvr_write_draw_indirect_elements_base_instance3_immediates(buffer) \ 125 do { \ 126 { \ 127 uint32_t data = 0x0; \ 128 PVR_PDS_PRINT_DATA("DRAW_INDIRECT_ELEMENTS", data, 0); \ 129 memcpy(buffer + 2, &data, sizeof(data)); \ 130 } \ 131 { \ 132 uint64_t data = 0x0; \ 133 PVR_PDS_PRINT_DATA("DRAW_INDIRECT_ELEMENTS", data, 0); \ 134 memcpy(buffer + 8, &data, sizeof(data)); \ 135 } \ 136 { \ 137 uint32_t data = 0x1; \ 138 PVR_PDS_PRINT_DATA("DRAW_INDIRECT_ELEMENTS", data, 0); \ 139 memcpy(buffer + 10, &data, sizeof(data)); \ 140 } \ 141 } while (0) 142 #endif 143