| 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 |
#include <assert.h> |
| 25 |
#include <stdbool.h> |
| 26 |
#include <stdint.h> |
| 27 |
#include <stdio.h> |
| 28 |
#include <string.h> |
| 29 |
|
| 30 |
#include "pvr_device_info.h" |
| 31 |
#include "pvr_pds.h" |
| 32 |
#include "pvr_rogue_pds_defs.h" |
| 33 |
#include "pvr_rogue_pds_disasm.h" |
| 34 |
#include "pvr_rogue_pds_encode.h" |
| 35 |
#include "util/log.h" |
| 36 |
#include "util/macros.h" |
| 37 |
|
| 38 |
#define H32(X) (uint32_t)((((X) >> 32U) & 0xFFFFFFFFUL)) |
| 39 |
#define L32(X) (uint32_t)(((X) & 0xFFFFFFFFUL)) |
| 40 |
|
| 41 |
/***************************************************************************** |
| 42 |
Macro definitions |
| 43 |
*****************************************************************************/ |
| 44 |
|
| 45 |
#define PVR_PDS_DWORD_SHIFT 2 |
| 46 |
|
| 47 |
#define PVR_PDS_CONSTANTS_BLOCK_BASE 0 |
| 48 |
#define PVR_PDS_CONSTANTS_BLOCK_SIZE 128 |
| 49 |
#define PVR_PDS_TEMPS_BLOCK_BASE 128 |
| 50 |
#define PVR_PDS_TEMPS_BLOCK_SIZE 32 |
| 51 |
|
| 52 |
#define PVR_ROGUE_PDSINST_ST_COUNT4_MAX_SIZE PVR_ROGUE_PDSINST_ST_COUNT4_MASK |
| 53 |
#define PVR_ROGUE_PDSINST_LD_COUNT8_MAX_SIZE PVR_ROGUE_PDSINST_LD_COUNT8_MASK |
| 54 |
|
| 55 |
/* Map PDS temp registers to the CDM values they contain Work-group IDs are only |
| 56 |
* available in the coefficient sync task. |
| 57 |
*/ |
| 58 |
#define PVR_PDS_CDM_WORK_GROUP_ID_X 0 |
| 59 |
#define PVR_PDS_CDM_WORK_GROUP_ID_Y 1 |
| 60 |
#define PVR_PDS_CDM_WORK_GROUP_ID_Z 3 |
| 61 |
/* Local IDs are available in every task. */ |
| 62 |
#define PVR_PDS_CDM_LOCAL_ID_X 0 |
| 63 |
#define PVR_PDS_CDM_LOCAL_ID_YZ 1 |
| 64 |
|
| 65 |
#define PVR_PDS_DOUTW_LOWER32 0x0 |
| 66 |
#define PVR_PDS_DOUTW_UPPER32 0x1 |
| 67 |
#define PVR_PDS_DOUTW_LOWER64 0x2 |
| 68 |
#define PVR_PDS_DOUTW_LOWER128 0x3 |
| 69 |
#define PVR_PDS_DOUTW_MAXMASK 0x4 |
| 70 |
|
| 71 |
#define ROGUE_PDS_FIXED_PIXEL_SHADER_DATA_SIZE 8U |
| 72 |
#define PDS_ROGUE_TA_STATE_PDS_ADDR_ALIGNSIZE (16U) |
| 73 |
|
| 74 |
/***************************************************************************** |
| 75 |
Static variables |
| 76 |
*****************************************************************************/ |
| 77 |
|
| 78 |
static const uint32_t dword_mask_const[PVR_PDS_DOUTW_MAXMASK] = { |
| 79 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_BSIZE_LOWER, |
| 80 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_BSIZE_UPPER, |
| 81 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_BSIZE_ALL64, |
| 82 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_BSIZE_ALL64 |
| 83 |
}; |
| 84 |
|
| 85 |
/* If has_slc_mcu_cache_control is enabled use cache_control_const[0], else use |
| 86 |
* cache_control_const[1]. |
| 87 |
*/ |
| 88 |
static const uint32_t cache_control_const[2][2] = { |
| 89 |
{ PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_CMODE_BYPASS, |
| 90 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_CMODE_CACHED }, |
| 91 |
{ 0, 0 } |
| 92 |
}; |
| 93 |
|
| 94 |
static const uint32_t wg_id_temps[3] = { |
| 95 |
PVR_PDS_CDM_WORK_GROUP_ID_X, |
| 96 |
PVR_PDS_CDM_WORK_GROUP_ID_Y, |
| 97 |
PVR_PDS_CDM_WORK_GROUP_ID_Z, |
| 98 |
}; |
| 99 |
|
| 100 |
/***************************************************************************** |
| 101 |
Function definitions |
| 102 |
*****************************************************************************/ |
| 103 |
|
| 104 |
uint64_t pvr_pds_encode_ld_src0(uint64_t dest, |
| 105 |
uint64_t count8, |
| 106 |
uint64_t src_add, |
| 107 |
bool cached, |
| 108 |
const struct pvr_device_info *dev_info) |
| 109 |
{ |
| 110 |
uint64_t encoded = 0; |
| 111 |
|
| 112 |
if (PVR_HAS_FEATURE(dev_info, slc_mcu_cache_controls)) { |
| 113 |
encoded |= (cached ? PVR_ROGUE_PDSINST_LD_LD_SRC0_SLCMODE_CACHED |
| 114 |
: PVR_ROGUE_PDSINST_LD_LD_SRC0_SLCMODE_BYPASS); |
| 115 |
} |
| 116 |
|
| 117 |
encoded |= ((src_add & PVR_ROGUE_PDSINST_LD_SRCADD_MASK) |
| 118 |
<< PVR_ROGUE_PDSINST_LD_LD_SRC0_SRCADD_SHIFT); |
| 119 |
encoded |= ((count8 & PVR_ROGUE_PDSINST_LD_COUNT8_MASK) |
| 120 |
<< PVR_ROGUE_PDSINST_LD_LD_SRC0_COUNT8_SHIFT); |
| 121 |
encoded |= (cached ? PVR_ROGUE_PDSINST_LD_LD_SRC0_CMODE_CACHED |
| 122 |
: PVR_ROGUE_PDSINST_LD_LD_SRC0_CMODE_BYPASS); |
| 123 |
encoded |= ((dest & PVR_ROGUE_PDSINST_REGS64TP_MASK) |
| 124 |
<< PVR_ROGUE_PDSINST_LD_LD_SRC0_DEST_SHIFT); |
| 125 |
|
| 126 |
return encoded; |
| 127 |
} |
| 128 |
|
| 129 |
uint64_t pvr_pds_encode_st_src0(uint64_t src, |
| 130 |
uint64_t count4, |
| 131 |
uint64_t dst_add, |
| 132 |
bool write_through, |
| 133 |
const struct pvr_device_info *device_info) |
| 134 |
{ |
| 135 |
uint64_t encoded = 0; |
| 136 |
|
| 137 |
if (device_info->features.has_slc_mcu_cache_controls) { |
| 138 |
encoded |= (write_through |
| 139 |
? PVR_ROGUE_PDSINST_ST_ST_SRC0_SLCMODE_WRITE_THROUGH |
| 140 |
: PVR_ROGUE_PDSINST_ST_ST_SRC0_SLCMODE_WRITE_BACK); |
| 141 |
} |
| 142 |
|
| 143 |
encoded |= ((dst_add & PVR_ROGUE_PDSINST_ST_SRCADD_MASK) |
| 144 |
<< PVR_ROGUE_PDSINST_ST_ST_SRC0_DSTADD_SHIFT); |
| 145 |
encoded |= ((count4 & PVR_ROGUE_PDSINST_ST_COUNT4_MASK) |
| 146 |
<< PVR_ROGUE_PDSINST_ST_ST_SRC0_COUNT4_SHIFT); |
| 147 |
encoded |= (write_through ? PVR_ROGUE_PDSINST_ST_ST_SRC0_CMODE_WRITE_THROUGH |
| 148 |
: PVR_ROGUE_PDSINST_ST_ST_SRC0_CMODE_WRITE_BACK); |
| 149 |
encoded |= ((src & PVR_ROGUE_PDSINST_REGS32TP_MASK) |
| 150 |
<< PVR_ROGUE_PDSINST_ST_ST_SRC0_SRC_SHIFT); |
| 151 |
|
| 152 |
return encoded; |
| 153 |
} |
| 154 |
|
| 155 |
static ALWAYS_INLINE uint32_t |
| 156 |
pvr_pds_encode_doutw_src1(uint32_t dest, |
| 157 |
uint32_t dword_mask, |
| 158 |
uint32_t flags, |
| 159 |
bool cached, |
| 160 |
const struct pvr_device_info *dev_info) |
| 161 |
{ |
| 162 |
assert(((dword_mask > PVR_PDS_DOUTW_LOWER64) && ((dest & 3) == 0)) || |
| 163 |
((dword_mask == PVR_PDS_DOUTW_LOWER64) && ((dest & 1) == 0)) || |
| 164 |
(dword_mask < PVR_PDS_DOUTW_LOWER64)); |
| 165 |
|
| 166 |
uint32_t encoded = |
| 167 |
(dest << PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_AO_SHIFT); |
| 168 |
|
| 169 |
encoded |= dword_mask_const[dword_mask]; |
| 170 |
|
| 171 |
encoded |= flags; |
| 172 |
|
| 173 |
encoded |= |
| 174 |
cache_control_const[PVR_HAS_FEATURE(dev_info, slc_mcu_cache_controls) ? 0 |
| 175 |
: 1] |
| 176 |
[cached ? 1 : 0]; |
| 177 |
return encoded; |
| 178 |
} |
| 179 |
|
| 180 |
static ALWAYS_INLINE uint32_t pvr_pds_encode_doutw64(uint32_t cc, |
| 181 |
uint32_t end, |
| 182 |
uint32_t src1, |
| 183 |
uint32_t src0) |
| 184 |
{ |
| 185 |
return pvr_pds_inst_encode_dout(cc, |
| 186 |
end, |
| 187 |
src1, |
| 188 |
src0, |
| 189 |
PVR_ROGUE_PDSINST_DSTDOUT_DOUTW); |
| 190 |
} |
| 191 |
|
| 192 |
static ALWAYS_INLINE uint32_t pvr_pds_encode_doutu(uint32_t cc, |
| 193 |
uint32_t end, |
| 194 |
uint32_t src0) |
| 195 |
{ |
| 196 |
return pvr_pds_inst_encode_dout(cc, |
| 197 |
end, |
| 198 |
0, |
| 199 |
src0, |
| 200 |
PVR_ROGUE_PDSINST_DSTDOUT_DOUTU); |
| 201 |
} |
| 202 |
|
| 203 |
static ALWAYS_INLINE uint32_t pvr_pds_inst_encode_doutc(uint32_t cc, |
| 204 |
uint32_t end) |
| 205 |
{ |
| 206 |
return pvr_pds_inst_encode_dout(cc, |
| 207 |
end, |
| 208 |
0, |
| 209 |
0, |
| 210 |
PVR_ROGUE_PDSINST_DSTDOUT_DOUTC); |
| 211 |
} |
| 212 |
|
| 213 |
static ALWAYS_INLINE uint32_t pvr_pds_encode_doutd(uint32_t cc, |
| 214 |
uint32_t end, |
| 215 |
uint32_t src1, |
| 216 |
uint32_t src0) |
| 217 |
{ |
| 218 |
return pvr_pds_inst_encode_dout(cc, |
| 219 |
end, |
| 220 |
src1, |
| 221 |
src0, |
| 222 |
PVR_ROGUE_PDSINST_DSTDOUT_DOUTD); |
| 223 |
} |
| 224 |
|
| 225 |
static ALWAYS_INLINE uint32_t pvr_pds_encode_douti(uint32_t cc, |
| 226 |
uint32_t end, |
| 227 |
uint32_t src0) |
| 228 |
{ |
| 229 |
return pvr_pds_inst_encode_dout(cc, |
| 230 |
end, |
| 231 |
0, |
| 232 |
src0, |
| 233 |
PVR_ROGUE_PDSINST_DSTDOUT_DOUTI); |
| 234 |
} |
| 235 |
|
| 236 |
static ALWAYS_INLINE uint32_t pvr_pds_encode_bra(uint32_t srcc, |
| 237 |
uint32_t neg, |
| 238 |
uint32_t setc, |
| 239 |
int32_t relative_address) |
| 240 |
{ |
| 241 |
/* Address should be signed but API only allows unsigned value. */ |
| 242 |
return pvr_pds_inst_encode_bra(srcc, neg, setc, (uint32_t)relative_address); |
| 243 |
} |
| 244 |
|
| 245 |
/** |
| 246 |
* Gets the next constant address and moves the next constant pointer along. |
| 247 |
* |
| 248 |
* \param next_constant Pointer to the next constant address. |
| 249 |
* \param num_constants The number of constants required. |
| 250 |
* \param count The number of constants allocated. |
| 251 |
* \return The address of the next constant. |
| 252 |
*/ |
| 253 |
static uint32_t pvr_pds_get_constants(uint32_t *next_constant, |
| 254 |
uint32_t num_constants, |
| 255 |
uint32_t *count) |
| 256 |
{ |
| 257 |
uint32_t constant; |
| 258 |
|
| 259 |
/* Work out starting constant number. For even number of constants, start on |
| 260 |
* a 64-bit boundary. |
| 261 |
*/ |
| 262 |
if (num_constants & 1) |
| 263 |
constant = *next_constant; |
| 264 |
else |
| 265 |
constant = (*next_constant + 1) & ~1; |
| 266 |
|
| 267 |
/* Update the count with the number of constants actually allocated. */ |
| 268 |
*count += constant + num_constants - *next_constant; |
| 269 |
|
| 270 |
/* Move the next constant pointer. */ |
| 271 |
*next_constant = constant + num_constants; |
| 272 |
|
| 273 |
assert((constant + num_constants) <= PVR_PDS_CONSTANTS_BLOCK_SIZE); |
| 274 |
|
| 275 |
return constant; |
| 276 |
} |
| 277 |
|
| 278 |
/** |
| 279 |
* Gets the next temp address and moves the next temp pointer along. |
| 280 |
* |
| 281 |
* \param next_temp Pointer to the next temp address. |
| 282 |
* \param num_temps The number of temps required. |
| 283 |
* \param count The number of temps allocated. |
| 284 |
* \return The address of the next temp. |
| 285 |
*/ |
| 286 |
static uint32_t |
| 287 |
pvr_pds_get_temps(uint32_t *next_temp, uint32_t num_temps, uint32_t *count) |
| 288 |
{ |
| 289 |
uint32_t temp; |
| 290 |
|
| 291 |
/* Work out starting temp number. For even number of temps, start on a |
| 292 |
* 64-bit boundary. |
| 293 |
*/ |
| 294 |
if (num_temps & 1) |
| 295 |
temp = *next_temp; |
| 296 |
else |
| 297 |
temp = (*next_temp + 1) & ~1; |
| 298 |
|
| 299 |
/* Update the count with the number of temps actually allocated. */ |
| 300 |
*count += temp + num_temps - *next_temp; |
| 301 |
|
| 302 |
/* Move the next temp pointer. */ |
| 303 |
*next_temp = temp + num_temps; |
| 304 |
|
| 305 |
assert((temp + num_temps) <= |
| 306 |
(PVR_PDS_TEMPS_BLOCK_SIZE + PVR_PDS_TEMPS_BLOCK_BASE)); |
| 307 |
|
| 308 |
return temp; |
| 309 |
} |
| 310 |
|
| 311 |
/** |
| 312 |
* Write a 32-bit constant indexed by the long range. |
| 313 |
* |
| 314 |
* \param data_block Pointer to data block to write to. |
| 315 |
* \param index Index within the data to write to. |
| 316 |
* \param dword The 32-bit constant to write. |
| 317 |
*/ |
| 318 |
static void |
| 319 |
pvr_pds_write_constant32(uint32_t *data_block, uint32_t index, uint32_t dword0) |
| 320 |
{ |
| 321 |
/* Check range. */ |
| 322 |
assert(index <= (PVR_ROGUE_PDSINST_REGS32_CONST32_UPPER - |
| 323 |
PVR_ROGUE_PDSINST_REGS32_CONST32_LOWER)); |
| 324 |
|
| 325 |
data_block[index + 0] = dword0; |
| 326 |
|
| 327 |
PVR_PDS_PRINT_DATA("WriteConstant32", (uint64_t)dword0, index); |
| 328 |
} |
| 329 |
|
| 330 |
/** |
| 331 |
* Write a 64-bit constant indexed by the long range. |
| 332 |
* |
| 333 |
* \param data_block Pointer to data block to write to. |
| 334 |
* \param index Index within the data to write to. |
| 335 |
* \param dword0 Lower half of the 64 bit constant. |
| 336 |
* \param dword1 Upper half of the 64 bit constant. |
| 337 |
*/ |
| 338 |
static void pvr_pds_write_constant64(uint32_t *data_block, |
| 339 |
uint32_t index, |
| 340 |
uint32_t dword0, |
| 341 |
uint32_t dword1) |
| 342 |
{ |
| 343 |
/* Has to be on 64 bit boundary. */ |
| 344 |
assert((index & 1) == 0); |
| 345 |
|
| 346 |
/* Check range. */ |
| 347 |
assert((index >> 1) <= (PVR_ROGUE_PDSINST_REGS64_CONST64_UPPER - |
| 348 |
PVR_ROGUE_PDSINST_REGS64_CONST64_LOWER)); |
| 349 |
|
| 350 |
data_block[index + 0] = dword0; |
| 351 |
data_block[index + 1] = dword1; |
| 352 |
|
| 353 |
PVR_PDS_PRINT_DATA("WriteConstant64", |
| 354 |
((uint64_t)dword0 << 32) | (uint64_t)dword1, |
| 355 |
index); |
| 356 |
} |
| 357 |
|
| 358 |
/** |
| 359 |
* Write a 64-bit constant from a single wide word indexed by the long-range |
| 360 |
* number. |
| 361 |
* |
| 362 |
* \param data_block Pointer to data block to write to. |
| 363 |
* \param index Index within the data to write to. |
| 364 |
* \param word The 64-bit constant to write. |
| 365 |
*/ |
| 366 |
|
| 367 |
static void |
| 368 |
pvr_pds_write_wide_constant(uint32_t *data_block, uint32_t index, uint64_t word) |
| 369 |
{ |
| 370 |
/* Has to be on 64 bit boundary. */ |
| 371 |
assert((index & 1) == 0); |
| 372 |
|
| 373 |
/* Check range. */ |
| 374 |
assert((index >> 1) <= (PVR_ROGUE_PDSINST_REGS64_CONST64_UPPER - |
| 375 |
PVR_ROGUE_PDSINST_REGS64_CONST64_LOWER)); |
| 376 |
|
| 377 |
data_block[index + 0] = L32(word); |
| 378 |
data_block[index + 1] = H32(word); |
| 379 |
|
| 380 |
PVR_PDS_PRINT_DATA("WriteWideConstant", word, index); |
| 381 |
} |
| 382 |
|
| 383 |
static void pvr_pds_write_dma_address(uint32_t *data_block, |
| 384 |
uint32_t index, |
| 385 |
uint64_t address, |
| 386 |
bool coherent, |
| 387 |
const struct pvr_device_info *dev_info) |
| 388 |
{ |
| 389 |
/* Has to be on 64 bit boundary. */ |
| 390 |
assert((index & 1) == 0); |
| 391 |
|
| 392 |
if (PVR_HAS_FEATURE(dev_info, slc_mcu_cache_controls)) |
| 393 |
address |= PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTD_SRC0_SLCMODE_CACHED; |
| 394 |
|
| 395 |
/* Check range. */ |
| 396 |
assert((index >> 1) <= (PVR_ROGUE_PDSINST_REGS64_CONST64_UPPER - |
| 397 |
PVR_ROGUE_PDSINST_REGS64_CONST64_LOWER)); |
| 398 |
|
| 399 |
data_block[index + 0] = L32(address); |
| 400 |
data_block[index + 1] = H32(address); |
| 401 |
|
| 402 |
PVR_PDS_PRINT_DATA("WriteDMAAddress", address, index); |
| 403 |
} |
| 404 |
|
| 405 |
/** |
| 406 |
* External API to append a 64-bit constant to an existing data segment |
| 407 |
* allocation. |
| 408 |
* |
| 409 |
* \param constants Pointer to start of data segment. |
| 410 |
* \param constant_value Value to write to constant. |
| 411 |
* \param data_size The number of constants allocated. |
| 412 |
* \returns The address of the next constant. |
| 413 |
*/ |
| 414 |
uint32_t pvr_pds_append_constant64(uint32_t *constants, |
| 415 |
uint64_t constant_value, |
| 416 |
uint32_t *data_size) |
| 417 |
{ |
| 418 |
/* Calculate next constant from current data size. */ |
| 419 |
uint32_t next_constant = *data_size; |
| 420 |
uint32_t constant = pvr_pds_get_constants(&next_constant, 2, data_size); |
| 421 |
|
| 422 |
/* Set the value. */ |
| 423 |
pvr_pds_write_wide_constant(constants, constant, constant_value); |
| 424 |
|
| 425 |
return constant; |
| 426 |
} |
| 427 |
|
| 428 |
void pvr_pds_pixel_shader_sa_initialize( |
| 429 |
struct pvr_pds_pixel_shader_sa_program *program) |
| 430 |
{ |
| 431 |
memset(program, 0, sizeof(*program)); |
| 432 |
} |
| 433 |
|
| 434 |
/** |
| 435 |
* Encode a DMA burst. |
| 436 |
* |
| 437 |
* \param dma_control DMA control words. |
| 438 |
* \param dma_address DMA address. |
| 439 |
* \param dest_offset Destination offset in the attribute. |
| 440 |
* \param dma_size The size of the DMA in words. |
| 441 |
* \param src_address Source address for the burst. |
| 442 |
* \param last Last DMA in program. |
| 443 |
* \param dev_info PVR device info structure. |
| 444 |
* \returns The number of DMA transfers required. |
| 445 |
*/ |
| 446 |
uint32_t pvr_pds_encode_dma_burst(uint32_t *dma_control, |
| 447 |
uint64_t *dma_address, |
| 448 |
uint32_t dest_offset, |
| 449 |
uint32_t dma_size, |
| 450 |
uint64_t src_address, |
| 451 |
bool last, |
| 452 |
const struct pvr_device_info *dev_info) |
| 453 |
{ |
| 454 |
dma_control[0] = dma_size |
| 455 |
<< PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTD_SRC1_BSIZE_SHIFT; |
| 456 |
dma_control[0] |= dest_offset |
| 457 |
<< PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTD_SRC1_AO_SHIFT; |
| 458 |
|
| 459 |
dma_control[0] |= PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTD_SRC1_CMODE_CACHED | |
| 460 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTD_SRC1_DEST_COMMON_STORE; |
| 461 |
|
| 462 |
if (last) |
| 463 |
dma_control[0] |= PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTD_SRC1_LAST_EN; |
| 464 |
|
| 465 |
dma_address[0] = src_address; |
| 466 |
if (PVR_HAS_FEATURE(dev_info, slc_mcu_cache_controls)) |
| 467 |
dma_address[0] |= PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTD_SRC0_SLCMODE_CACHED; |
| 468 |
|
| 469 |
/* Force to 1 DMA. */ |
| 470 |
return 1; |
| 471 |
} |
| 472 |
|
| 473 |
/* FIXME: use the csbgen interface and pvr_csb_pack. |
| 474 |
* FIXME: use bool for phase_rate_change. |
| 475 |
*/ |
| 476 |
/** |
| 477 |
* Sets up the USC control words for a DOUTU. |
| 478 |
* |
| 479 |
* \param usc_task_control USC task control structure to be setup. |
| 480 |
* \param execution_address USC execution virtual address. |
| 481 |
* \param usc_temps Number of USC temps. |
| 482 |
* \param sample_rate Sample rate for the DOUTU. |
| 483 |
* \param phase_rate_change Phase rate change for the DOUTU. |
| 484 |
*/ |
| 485 |
void pvr_pds_setup_doutu(struct pvr_pds_usc_task_control *usc_task_control, |
| 486 |
uint64_t execution_address, |
| 487 |
uint32_t usc_temps, |
| 488 |
uint32_t sample_rate, |
| 489 |
bool phase_rate_change) |
| 490 |
{ |
| 491 |
usc_task_control->src0 = UINT64_C(0); |
| 492 |
|
| 493 |
/* Set the execution address. */ |
| 494 |
pvr_set_usc_execution_address64(&(usc_task_control->src0), |
| 495 |
execution_address); |
| 496 |
|
| 497 |
if (usc_temps > 0) { |
| 498 |
/* Temps are allocated in blocks of 4 dwords. */ |
| 499 |
usc_temps = |
| 500 |
DIV_ROUND_UP(usc_temps, |
| 501 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTU_SRC0_TEMPS_ALIGNSIZE); |
| 502 |
|
| 503 |
/* Check for losing temps due to too many requested. */ |
| 504 |
assert((usc_temps & PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTU_TEMPS_MASK) == |
| 505 |
usc_temps); |
| 506 |
|
| 507 |
usc_task_control->src0 |= |
| 508 |
((uint64_t)(usc_temps & |
| 509 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTU_TEMPS_MASK)) |
| 510 |
<< PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTU_SRC0_TEMPS_SHIFT; |
| 511 |
} |
| 512 |
|
| 513 |
if (sample_rate > 0) { |
| 514 |
usc_task_control->src0 |= |
| 515 |
((uint64_t)sample_rate) |
| 516 |
<< PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTU_SRC0_SAMPLE_RATE_SHIFT; |
| 517 |
} |
| 518 |
|
| 519 |
if (phase_rate_change) { |
| 520 |
usc_task_control->src0 |= |
| 521 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTU_SRC0_DUAL_PHASE_EN; |
| 522 |
} |
| 523 |
} |
| 524 |
|
| 525 |
/** |
| 526 |
* Generates the PDS pixel event program. |
| 527 |
* |
| 528 |
* \param program Pointer to the PDS pixel event program. |
| 529 |
* \param buffer Pointer to the buffer for the program. |
| 530 |
* \param gen_mode Generate either a data segment or code segment. |
| 531 |
* \param dev_info PVR device info structure. |
| 532 |
* \returns Pointer to just beyond the buffer for the program. |
| 533 |
*/ |
| 534 |
uint32_t * |
| 535 |
pvr_pds_generate_pixel_event(struct pvr_pds_event_program *restrict program, |
| 536 |
uint32_t *restrict buffer, |
| 537 |
enum pvr_pds_generate_mode gen_mode, |
| 538 |
const struct pvr_device_info *dev_info) |
| 539 |
{ |
| 540 |
uint32_t next_constant = PVR_PDS_CONSTANTS_BLOCK_BASE; |
| 541 |
uint32_t *constants = buffer; |
| 542 |
|
| 543 |
uint32_t data_size = 0; |
| 544 |
|
| 545 |
/* Copy the DMA control words and USC task control words to constants, then |
| 546 |
* arrange them so that the 64-bit words are together followed by the 32-bit |
| 547 |
* words. |
| 548 |
*/ |
| 549 |
uint32_t control_constant = |
| 550 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 551 |
uint32_t emit_constant = |
| 552 |
pvr_pds_get_constants(&next_constant, |
| 553 |
(2 * program->num_emit_word_pairs), |
| 554 |
&data_size); |
| 555 |
|
| 556 |
uint32_t control_word_constant = |
| 557 |
pvr_pds_get_constants(&next_constant, |
| 558 |
program->num_emit_word_pairs, |
| 559 |
&data_size); |
| 560 |
|
| 561 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 562 |
/* Src0 for DOUTU. */ |
| 563 |
pvr_pds_write_wide_constant(buffer, |
| 564 |
control_constant, |
| 565 |
program->task_control.src0); /* DOUTU */ |
| 566 |
/* 64-bit Src0. */ |
| 567 |
|
| 568 |
/* Emit words for end of tile program. */ |
| 569 |
for (uint32_t i = 0; i < program->num_emit_word_pairs; i++) { |
| 570 |
pvr_pds_write_constant64(constants, |
| 571 |
emit_constant + (2 * i), |
| 572 |
program->emit_words[(2 * i) + 0], |
| 573 |
program->emit_words[(2 * i) + 1]); |
| 574 |
} |
| 575 |
|
| 576 |
/* Control words. */ |
| 577 |
for (uint32_t i = 0; i < program->num_emit_word_pairs; i++) { |
| 578 |
uint32_t doutw = pvr_pds_encode_doutw_src1( |
| 579 |
(2 * i), |
| 580 |
PVR_PDS_DOUTW_LOWER64, |
| 581 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_COMMON_STORE, |
| 582 |
false, |
| 583 |
dev_info); |
| 584 |
|
| 585 |
if (i == (program->num_emit_word_pairs - 1)) |
| 586 |
doutw |= PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_LAST_EN; |
| 587 |
|
| 588 |
pvr_pds_write_constant32(constants, control_word_constant + i, doutw); |
| 589 |
} |
| 590 |
} |
| 591 |
|
| 592 |
else if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 593 |
/* DOUTW the state into the shared register. */ |
| 594 |
for (uint32_t i = 0; i < program->num_emit_word_pairs; i++) { |
| 595 |
*buffer++ = pvr_pds_encode_doutw64( |
| 596 |
/* cc */ 0, |
| 597 |
/* END */ 0, |
| 598 |
/* SRC1 */ (control_word_constant + i), /* DOUTW 32-bit Src1 */ |
| 599 |
/* SRC0 */ (emit_constant + (2 * i)) >> 1); /* DOUTW 64-bit Src0 |
| 600 |
*/ |
| 601 |
} |
| 602 |
|
| 603 |
/* Kick the USC. */ |
| 604 |
*buffer++ = pvr_pds_encode_doutu( |
| 605 |
/* cc */ 0, |
| 606 |
/* END */ 1, |
| 607 |
/* SRC0 */ control_constant >> 1); |
| 608 |
} |
| 609 |
|
| 610 |
uint32_t code_size = 1 + program->num_emit_word_pairs; |
| 611 |
|
| 612 |
/* Save the data segment Pointer and size. */ |
| 613 |
program->data_segment = constants; |
| 614 |
program->data_size = data_size; |
| 615 |
program->code_size = code_size; |
| 616 |
|
| 617 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) |
| 618 |
return (constants + next_constant); |
| 619 |
|
| 620 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) |
| 621 |
return buffer; |
| 622 |
|
| 623 |
return NULL; |
| 624 |
} |
| 625 |
|
| 626 |
/** |
| 627 |
* Checks if any of the vertex streams contains instance data. |
| 628 |
* |
| 629 |
* \param streams Streams contained in the vertex shader. |
| 630 |
* \param num_streams Number of vertex streams. |
| 631 |
* \returns true if one or more of the given vertex streams contains |
| 632 |
* instance data, otherwise false. |
| 633 |
*/ |
| 634 |
static bool pvr_pds_vertex_streams_contains_instance_data( |
| 635 |
const struct pvr_pds_vertex_stream *streams, |
| 636 |
uint32_t num_streams) |
| 637 |
{ |
| 638 |
for (uint32_t i = 0; i < num_streams; i++) { |
| 639 |
const struct pvr_pds_vertex_stream *vertex_stream = &streams[i]; |
| 640 |
if (vertex_stream->instance_data) |
| 641 |
return true; |
| 642 |
} |
| 643 |
|
| 644 |
return false; |
| 645 |
} |
| 646 |
|
| 647 |
static uint32_t pvr_pds_get_bank_based_constants(uint32_t num_backs, |
| 648 |
uint32_t *next_constant, |
| 649 |
uint32_t num_constants, |
| 650 |
uint32_t *count) |
| 651 |
{ |
| 652 |
/* Allocate constant for PDS vertex shader where constant is divided into |
| 653 |
* banks. |
| 654 |
*/ |
| 655 |
uint32_t constant; |
| 656 |
|
| 657 |
assert(num_constants == 1 || num_constants == 2); |
| 658 |
|
| 659 |
if (*next_constant >= (num_backs << 3)) |
| 660 |
return pvr_pds_get_constants(next_constant, num_constants, count); |
| 661 |
|
| 662 |
if ((*next_constant % 8) == 0) { |
| 663 |
constant = *next_constant; |
| 664 |
|
| 665 |
if (num_constants == 1) |
| 666 |
*next_constant += 1; |
| 667 |
else |
| 668 |
*next_constant += 8; |
| 669 |
} else if (num_constants == 1) { |
| 670 |
constant = *next_constant; |
| 671 |
*next_constant += 7; |
| 672 |
} else { |
| 673 |
*next_constant += 7; |
| 674 |
constant = *next_constant; |
| 675 |
|
| 676 |
if (*next_constant >= (num_backs << 3)) { |
| 677 |
*next_constant += 2; |
| 678 |
*count += 2; |
| 679 |
} else { |
| 680 |
*next_constant += 8; |
| 681 |
} |
| 682 |
} |
| 683 |
return constant; |
| 684 |
} |
| 685 |
|
| 686 |
/** |
| 687 |
* Generates a PDS program to load USC vertex inputs based from one or more |
| 688 |
* vertex buffers, each containing potentially multiple elements, and then a |
| 689 |
* DOUTU to execute the USC. |
| 690 |
* |
| 691 |
* \param program Pointer to the description of the program which should be |
| 692 |
* generated. |
| 693 |
* \param buffer Pointer to buffer that receives the output of this function. |
| 694 |
* Will either be the data segment or code segment depending on |
| 695 |
* gen_mode. |
| 696 |
* \param gen_mode Which part to generate, either data segment or |
| 697 |
* code segment. If PDS_GENERATE_SIZES is specified, nothing is |
| 698 |
* written, but size information in program is updated. |
| 699 |
* \param dev_info PVR device info structure. |
| 700 |
* \returns Pointer to just beyond the buffer for the data - i.e the value |
| 701 |
* of the buffer after writing its contents. |
| 702 |
*/ |
| 703 |
/* FIXME: Implement PDS_GENERATE_CODEDATA_SEGMENTS? */ |
| 704 |
uint32_t * |
| 705 |
pvr_pds_vertex_shader(struct pvr_pds_vertex_shader_program *restrict program, |
| 706 |
uint32_t *restrict buffer, |
| 707 |
enum pvr_pds_generate_mode gen_mode, |
| 708 |
const struct pvr_device_info *dev_info) |
| 709 |
{ |
| 710 |
uint32_t next_constant = PVR_PDS_CONSTANTS_BLOCK_BASE; |
| 711 |
uint32_t next_stream_constant; |
| 712 |
uint32_t next_temp; |
| 713 |
uint32_t usc_control_constant64; |
| 714 |
uint32_t stride_constant32 = 0; |
| 715 |
uint32_t dma_address_constant64 = 0; |
| 716 |
uint32_t dma_control_constant64; |
| 717 |
uint32_t multiplier_constant32 = 0; |
| 718 |
uint32_t base_instance_const32 = 0; |
| 719 |
|
| 720 |
uint32_t temp = 0; |
| 721 |
uint32_t index_temp64 = 0; |
| 722 |
uint32_t num_vertices_temp64 = 0; |
| 723 |
uint32_t pre_index_temp = (uint32_t)(-1); |
| 724 |
bool first_ddmadt = true; |
| 725 |
uint32_t input_register0; |
| 726 |
uint32_t input_register1; |
| 727 |
uint32_t input_register2; |
| 728 |
|
| 729 |
struct pvr_pds_vertex_stream *vertex_stream; |
| 730 |
struct pvr_pds_vertex_element *vertex_element; |
| 731 |
uint32_t shift_2s_comp; |
| 732 |
|
| 733 |
uint32_t data_size = 0; |
| 734 |
uint32_t code_size = 0; |
| 735 |
uint32_t temps_used = 0; |
| 736 |
|
| 737 |
bool direct_writes_needed = false; |
| 738 |
|
| 739 |
uint32_t consts_size = 0; |
| 740 |
uint32_t vertex_id_control_word_const32 = 0; |
| 741 |
uint32_t instance_id_control_word_const32 = 0; |
| 742 |
uint32_t instance_id_modifier_word_const32 = 0; |
| 743 |
uint32_t geometry_id_control_word_const64 = 0; |
| 744 |
uint32_t empty_dma_control_constant64 = 0; |
| 745 |
|
| 746 |
bool any_instanced_stream = |
| 747 |
pvr_pds_vertex_streams_contains_instance_data(program->streams, |
| 748 |
program->num_streams); |
| 749 |
|
| 750 |
uint32_t base_instance_register = 0; |
| 751 |
uint32_t ddmadt_enables = 0; |
| 752 |
|
| 753 |
bool issue_empty_ddmad = false; |
| 754 |
uint32_t last_stream_index = program->num_streams - 1; |
| 755 |
bool current_p0 = false; |
| 756 |
uint32_t skip_stream_flag = 0; |
| 757 |
|
| 758 |
/* Generate the PDS vertex shader data. */ |
| 759 |
|
| 760 |
#if MESA_DEBUG |
| 761 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 762 |
for (uint32_t i = 0; i < program->data_size; i++) |
| 763 |
buffer[i] = 0xDEADBEEF; |
| 764 |
} |
| 765 |
#endif |
| 766 |
|
| 767 |
/* Generate the PDS vertex shader program */ |
| 768 |
next_temp = PVR_PDS_TEMPS_BLOCK_BASE; |
| 769 |
/* IR0 is in first 32-bit temp, temp[0].32, vertex_Index. */ |
| 770 |
input_register0 = pvr_pds_get_temps(&next_temp, 1, &temps_used); |
| 771 |
/* IR1 is in second 32-bit temp, temp[1].32, instance_ID. */ |
| 772 |
input_register1 = pvr_pds_get_temps(&next_temp, 1, &temps_used); |
| 773 |
|
| 774 |
if (program->iterate_remap_id) |
| 775 |
input_register2 = pvr_pds_get_temps(&next_temp, 1, &temps_used); |
| 776 |
else |
| 777 |
input_register2 = 0; /* Not used, but need to silence the compiler. */ |
| 778 |
|
| 779 |
/* Generate the PDS vertex shader code. The constants in the data block are |
| 780 |
* arranged as follows: |
| 781 |
* |
| 782 |
* 64 bit bank 0 64 bit bank 1 64 bit bank 2 64 bit bank |
| 783 |
* 3 Not used (tmps) Stride | Multiplier Address Control |
| 784 |
*/ |
| 785 |
|
| 786 |
/* Find out how many constants are needed by streams. */ |
| 787 |
for (uint32_t stream = 0; stream < program->num_streams; stream++) { |
| 788 |
pvr_pds_get_constants(&next_constant, |
| 789 |
8 * program->streams[stream].num_elements, |
| 790 |
&consts_size); |
| 791 |
} |
| 792 |
|
| 793 |
/* If there are no vertex streams allocate the first bank for USC Code |
| 794 |
* Address. |
| 795 |
*/ |
| 796 |
if (consts_size == 0) |
| 797 |
pvr_pds_get_constants(&next_constant, 2, &consts_size); |
| 798 |
else |
| 799 |
next_constant = 8; |
| 800 |
|
| 801 |
direct_writes_needed = program->iterate_instance_id || |
| 802 |
program->iterate_vtx_id || program->iterate_remap_id; |
| 803 |
|
| 804 |
if (!PVR_HAS_FEATURE(dev_info, pds_ddmadt)) { |
| 805 |
/* Evaluate what config of DDMAD should be used for each stream. */ |
| 806 |
for (uint32_t stream = 0; stream < program->num_streams; stream++) { |
| 807 |
vertex_stream = &program->streams[stream]; |
| 808 |
|
| 809 |
if (vertex_stream->use_ddmadt) { |
| 810 |
ddmadt_enables |= (1 << stream); |
| 811 |
|
| 812 |
/* The condition for index value is: |
| 813 |
* index * stride + size <= bufferSize (all in unit of byte) |
| 814 |
*/ |
| 815 |
if (vertex_stream->stride == 0) { |
| 816 |
if (vertex_stream->elements[0].size <= |
| 817 |
vertex_stream->buffer_size_in_bytes) { |
| 818 |
/* index can be any value -> no need to use DDMADT. */ |
| 819 |
ddmadt_enables &= (~(1 << stream)); |
| 820 |
} else { |
| 821 |
/* No index works -> no need to issue DDMAD instruction. |
| 822 |
*/ |
| 823 |
skip_stream_flag |= (1 << stream); |
| 824 |
} |
| 825 |
} else { |
| 826 |
/* index * stride + size <= bufferSize |
| 827 |
* |
| 828 |
* can be converted to: |
| 829 |
* index <= (bufferSize - size) / stride |
| 830 |
* |
| 831 |
* where maximum index is: |
| 832 |
* integer((bufferSize - size) / stride). |
| 833 |
*/ |
| 834 |
if (vertex_stream->buffer_size_in_bytes < |
| 835 |
vertex_stream->elements[0].size) { |
| 836 |
/* No index works -> no need to issue DDMAD instruction. |
| 837 |
*/ |
| 838 |
skip_stream_flag |= (1 << stream); |
| 839 |
} else { |
| 840 |
uint32_t max_index = (vertex_stream->buffer_size_in_bytes - |
| 841 |
vertex_stream->elements[0].size) / |
| 842 |
vertex_stream->stride; |
| 843 |
if (max_index == 0xFFFFFFFFu) { |
| 844 |
/* No need to use DDMADT as all possible indices can |
| 845 |
* pass the test. |
| 846 |
*/ |
| 847 |
ddmadt_enables &= (~(1 << stream)); |
| 848 |
} else { |
| 849 |
/* In this case, test condition can be changed to |
| 850 |
* index < max_index + 1. |
| 851 |
*/ |
| 852 |
program->streams[stream].num_vertices = |
| 853 |
pvr_pds_get_bank_based_constants(program->num_streams, |
| 854 |
&next_constant, |
| 855 |
1, |
| 856 |
&consts_size); |
| 857 |
|
| 858 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 859 |
pvr_pds_write_constant32( |
| 860 |
buffer, |
| 861 |
program->streams[stream].num_vertices, |
| 862 |
max_index + 1); |
| 863 |
} |
| 864 |
} |
| 865 |
} |
| 866 |
} |
| 867 |
} |
| 868 |
|
| 869 |
if ((skip_stream_flag & (1 << stream)) == 0) { |
| 870 |
issue_empty_ddmad = (ddmadt_enables & (1 << stream)) != 0; |
| 871 |
last_stream_index = stream; |
| 872 |
} |
| 873 |
} |
| 874 |
} else { |
| 875 |
if (program->num_streams > 0 && |
| 876 |
program->streams[program->num_streams - 1].use_ddmadt) { |
| 877 |
issue_empty_ddmad = true; |
| 878 |
} |
| 879 |
} |
| 880 |
|
| 881 |
if (direct_writes_needed) |
| 882 |
issue_empty_ddmad = false; |
| 883 |
|
| 884 |
if (issue_empty_ddmad) { |
| 885 |
/* An empty DMA control const (DMA size = 0) is required in case the |
| 886 |
* last DDMADD is predicated out and last flag does not have any usage. |
| 887 |
*/ |
| 888 |
empty_dma_control_constant64 = |
| 889 |
pvr_pds_get_bank_based_constants(program->num_streams, |
| 890 |
&next_constant, |
| 891 |
2, |
| 892 |
&consts_size); |
| 893 |
} |
| 894 |
|
| 895 |
/* Assign constants for non stream or base instance if there is any |
| 896 |
* instanced stream. |
| 897 |
*/ |
| 898 |
if (direct_writes_needed || any_instanced_stream || |
| 899 |
program->instance_id_modifier) { |
| 900 |
if (program->iterate_vtx_id) { |
| 901 |
vertex_id_control_word_const32 = |
| 902 |
pvr_pds_get_bank_based_constants(program->num_streams, |
| 903 |
&next_constant, |
| 904 |
1, |
| 905 |
&consts_size); |
| 906 |
} |
| 907 |
|
| 908 |
if (program->iterate_instance_id || program->instance_id_modifier) { |
| 909 |
if (program->instance_id_modifier == 0) { |
| 910 |
instance_id_control_word_const32 = |
| 911 |
pvr_pds_get_bank_based_constants(program->num_streams, |
| 912 |
&next_constant, |
| 913 |
1, |
| 914 |
&consts_size); |
| 915 |
} else { |
| 916 |
instance_id_modifier_word_const32 = |
| 917 |
pvr_pds_get_bank_based_constants(program->num_streams, |
| 918 |
&next_constant, |
| 919 |
1, |
| 920 |
&consts_size); |
| 921 |
if ((instance_id_modifier_word_const32 % 2) == 0) { |
| 922 |
instance_id_control_word_const32 = |
| 923 |
pvr_pds_get_bank_based_constants(program->num_streams, |
| 924 |
&next_constant, |
| 925 |
1, |
| 926 |
&consts_size); |
| 927 |
} else { |
| 928 |
instance_id_control_word_const32 = |
| 929 |
instance_id_modifier_word_const32; |
| 930 |
instance_id_modifier_word_const32 = |
| 931 |
pvr_pds_get_bank_based_constants(program->num_streams, |
| 932 |
&next_constant, |
| 933 |
1, |
| 934 |
&consts_size); |
| 935 |
} |
| 936 |
} |
| 937 |
} |
| 938 |
|
| 939 |
if (program->base_instance != 0) { |
| 940 |
base_instance_const32 = |
| 941 |
pvr_pds_get_bank_based_constants(program->num_streams, |
| 942 |
&next_constant, |
| 943 |
1, |
| 944 |
&consts_size); |
| 945 |
} |
| 946 |
|
| 947 |
if (program->iterate_remap_id) { |
| 948 |
geometry_id_control_word_const64 = |
| 949 |
pvr_pds_get_bank_based_constants(program->num_streams, |
| 950 |
&next_constant, |
| 951 |
2, |
| 952 |
&consts_size); |
| 953 |
} |
| 954 |
} |
| 955 |
|
| 956 |
if (program->instance_id_modifier != 0) { |
| 957 |
/* This instanceID modifier is used when a draw array instanced call |
| 958 |
* sourcing from client data cannot fit into vertex buffer and needs to |
| 959 |
* be broken down into several draw calls. |
| 960 |
*/ |
| 961 |
|
| 962 |
code_size += 1; |
| 963 |
|
| 964 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 965 |
pvr_pds_write_constant32(buffer, |
| 966 |
instance_id_modifier_word_const32, |
| 967 |
program->instance_id_modifier); |
| 968 |
} else if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 969 |
*buffer++ = pvr_pds_inst_encode_add32( |
| 970 |
/* cc */ 0x0, |
| 971 |
/* ALUM */ 0, /* Unsigned */ |
| 972 |
/* SNA */ 0, /* Add */ |
| 973 |
/* SRC0 32b */ instance_id_modifier_word_const32, |
| 974 |
/* SRC1 32b */ input_register1, |
| 975 |
/* DST 32b */ input_register1); |
| 976 |
} |
| 977 |
} |
| 978 |
|
| 979 |
/* Adjust instanceID if necessary. */ |
| 980 |
if (any_instanced_stream || program->iterate_instance_id) { |
| 981 |
if (program->base_instance != 0) { |
| 982 |
assert(!program->draw_indirect); |
| 983 |
|
| 984 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 985 |
pvr_pds_write_constant32(buffer, |
| 986 |
base_instance_const32, |
| 987 |
program->base_instance); |
| 988 |
} |
| 989 |
|
| 990 |
base_instance_register = base_instance_const32; |
| 991 |
} |
| 992 |
|
| 993 |
if (program->draw_indirect) { |
| 994 |
assert((program->instance_id_modifier == 0) && |
| 995 |
(program->base_instance == 0)); |
| 996 |
|
| 997 |
base_instance_register = PVR_ROGUE_PDSINST_REGS32_PTEMP32_LOWER + 1; |
| 998 |
} |
| 999 |
} |
| 1000 |
|
| 1001 |
next_constant = next_stream_constant = PVR_PDS_CONSTANTS_BLOCK_BASE; |
| 1002 |
usc_control_constant64 = |
| 1003 |
pvr_pds_get_constants(&next_stream_constant, 2, &data_size); |
| 1004 |
|
| 1005 |
for (uint32_t stream = 0; stream < program->num_streams; stream++) { |
| 1006 |
bool instance_data_with_base_instance; |
| 1007 |
|
| 1008 |
if ((!PVR_HAS_FEATURE(dev_info, pds_ddmadt)) && |
| 1009 |
((skip_stream_flag & (1 << stream)) != 0)) { |
| 1010 |
continue; |
| 1011 |
} |
| 1012 |
|
| 1013 |
vertex_stream = &program->streams[stream]; |
| 1014 |
|
| 1015 |
instance_data_with_base_instance = |
| 1016 |
((vertex_stream->instance_data) && |
| 1017 |
((program->base_instance > 0) || (program->draw_indirect))); |
| 1018 |
|
| 1019 |
/* Get all 8 32-bit constants at once, only 6 for first stream due to |
| 1020 |
* USC constants. |
| 1021 |
*/ |
| 1022 |
if (stream == 0) { |
| 1023 |
stride_constant32 = |
| 1024 |
pvr_pds_get_constants(&next_stream_constant, 6, &data_size); |
| 1025 |
} else { |
| 1026 |
next_constant = |
| 1027 |
pvr_pds_get_constants(&next_stream_constant, 8, &data_size); |
| 1028 |
|
| 1029 |
/* Skip bank 0. */ |
| 1030 |
stride_constant32 = next_constant + 2; |
| 1031 |
} |
| 1032 |
|
| 1033 |
multiplier_constant32 = stride_constant32 + 1; |
| 1034 |
|
| 1035 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 1036 |
pvr_pds_write_constant32(buffer, |
| 1037 |
stride_constant32, |
| 1038 |
vertex_stream->stride); |
| 1039 |
|
| 1040 |
/* Vertex stream frequency multiplier. */ |
| 1041 |
if (vertex_stream->multiplier) |
| 1042 |
pvr_pds_write_constant32(buffer, |
| 1043 |
multiplier_constant32, |
| 1044 |
vertex_stream->multiplier); |
| 1045 |
} |
| 1046 |
|
| 1047 |
/* Update the code size count and temps count for the above code |
| 1048 |
* segment. |
| 1049 |
*/ |
| 1050 |
if (vertex_stream->current_state) { |
| 1051 |
code_size += 1; |
| 1052 |
temp = pvr_pds_get_temps(&next_temp, 1, &temps_used); /* 32-bit */ |
| 1053 |
} else { |
| 1054 |
unsigned int num_temps_required = 0; |
| 1055 |
|
| 1056 |
if (vertex_stream->multiplier) { |
| 1057 |
num_temps_required += 2; |
| 1058 |
code_size += 3; |
| 1059 |
|
| 1060 |
if (vertex_stream->shift) { |
| 1061 |
code_size += 1; |
| 1062 |
|
| 1063 |
if ((int32_t)vertex_stream->shift > 0) |
| 1064 |
code_size += 1; |
| 1065 |
} |
| 1066 |
} else if (vertex_stream->shift) { |
| 1067 |
code_size += 1; |
| 1068 |
num_temps_required += 1; |
| 1069 |
} else if (instance_data_with_base_instance) { |
| 1070 |
num_temps_required += 1; |
| 1071 |
} |
| 1072 |
|
| 1073 |
if (num_temps_required != 0) { |
| 1074 |
temp = pvr_pds_get_temps(&next_temp, |
| 1075 |
num_temps_required, |
| 1076 |
&temps_used); /* 64-bit */ |
| 1077 |
} else { |
| 1078 |
temp = vertex_stream->instance_data ? input_register1 |
| 1079 |
: input_register0; |
| 1080 |
} |
| 1081 |
|
| 1082 |
if (instance_data_with_base_instance) |
| 1083 |
code_size += 1; |
| 1084 |
} |
| 1085 |
|
| 1086 |
/* The real code segment. */ |
| 1087 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 1088 |
/* If it's current state stream, then index = 0 always. */ |
| 1089 |
if (vertex_stream->current_state) { |
| 1090 |
/* Put zero in temp. */ |
| 1091 |
*buffer++ = pvr_pds_inst_encode_limm(0, temp, 0, 0); |
| 1092 |
} else if (vertex_stream->multiplier) { |
| 1093 |
/* old: Iout = (Iin * (Multiplier+2^24)) >> (Shift+24) |
| 1094 |
* new: Iout = (Iin * Multiplier) >> (shift+31) |
| 1095 |
*/ |
| 1096 |
|
| 1097 |
/* Put zero in temp. Need zero for add part of the following |
| 1098 |
* MAD. MAD source is 64 bit, so need two LIMMs. |
| 1099 |
*/ |
| 1100 |
*buffer++ = pvr_pds_inst_encode_limm(0, temp, 0, 0); |
| 1101 |
/* Put zero in temp. Need zero for add part of the following |
| 1102 |
* MAD. |
| 1103 |
*/ |
| 1104 |
*buffer++ = pvr_pds_inst_encode_limm(0, temp + 1, 0, 0); |
| 1105 |
|
| 1106 |
/* old: (Iin * (Multiplier+2^24)) |
| 1107 |
* new: (Iin * Multiplier) |
| 1108 |
*/ |
| 1109 |
*buffer++ = pvr_rogue_inst_encode_mad( |
| 1110 |
0, /* Sign of add is positive. */ |
| 1111 |
0, /* Unsigned ALU mode */ |
| 1112 |
0, /* Unconditional */ |
| 1113 |
multiplier_constant32, |
| 1114 |
vertex_stream->instance_data ? input_register1 : input_register0, |
| 1115 |
temp / 2, |
| 1116 |
temp / 2); |
| 1117 |
|
| 1118 |
if (vertex_stream->shift) { |
| 1119 |
int32_t shift = (int32_t)vertex_stream->shift; |
| 1120 |
|
| 1121 |
/* new: >> (shift + 31) */ |
| 1122 |
shift += 31; |
| 1123 |
shift *= -1; |
| 1124 |
|
| 1125 |
if (shift < -31) { |
| 1126 |
/* >> (31) */ |
| 1127 |
shift_2s_comp = 0xFFFE1; |
| 1128 |
*buffer++ = pvr_pds_inst_encode_sftlp64( |
| 1129 |
/* cc */ 0, |
| 1130 |
/* LOP */ PVR_ROGUE_PDSINST_LOP_NONE, |
| 1131 |
/* IM */ 1, /* enable immediate */ |
| 1132 |
/* SRC0 */ temp / 2, |
| 1133 |
/* SRC1 */ input_register0, /* This won't be used in |
| 1134 |
* a shift operation. |
| 1135 |
*/ |
| 1136 |
/* SRC2 (Shift) */ shift_2s_comp, |
| 1137 |
/* DST */ temp / 2); |
| 1138 |
shift += 31; |
| 1139 |
} |
| 1140 |
|
| 1141 |
/* old: >> (Shift+24) |
| 1142 |
* new: >> (shift + 31) |
| 1143 |
*/ |
| 1144 |
shift_2s_comp = *((uint32_t *)&shift); |
| 1145 |
*buffer++ = pvr_pds_inst_encode_sftlp64( |
| 1146 |
/* cc */ 0, |
| 1147 |
/* LOP */ PVR_ROGUE_PDSINST_LOP_NONE, |
| 1148 |
/* IM */ 1, /*enable immediate */ |
| 1149 |
/* SRC0 */ temp / 2, |
| 1150 |
/* SRC1 */ input_register0, /* This won't be used in |
| 1151 |
* a shift operation. |
| 1152 |
*/ |
| 1153 |
/* SRC2 (Shift) */ shift_2s_comp, |
| 1154 |
/* DST */ temp / 2); |
| 1155 |
} |
| 1156 |
|
| 1157 |
if (instance_data_with_base_instance) { |
| 1158 |
*buffer++ = |
| 1159 |
pvr_pds_inst_encode_add32(0, /* cc */ |
| 1160 |
0, /* ALNUM */ |
| 1161 |
0, /* SNA */ |
| 1162 |
base_instance_register, /* src0 |
| 1163 |
*/ |
| 1164 |
temp, /* src1 */ |
| 1165 |
temp /* dst */ |
| 1166 |
); |
| 1167 |
} |
| 1168 |
} else { /* NOT vertex_stream->multiplier */ |
| 1169 |
if (vertex_stream->shift) { |
| 1170 |
/* Shift Index/InstanceNum Right by shift bits. Put result |
| 1171 |
* in a Temp. |
| 1172 |
*/ |
| 1173 |
|
| 1174 |
/* 2's complement of shift as this will be a right shift. */ |
| 1175 |
shift_2s_comp = ~(vertex_stream->shift) + 1; |
| 1176 |
|
| 1177 |
*buffer++ = pvr_pds_inst_encode_sftlp32( |
| 1178 |
/* IM */ 1, /* enable immediate. */ |
| 1179 |
/* cc */ 0, |
| 1180 |
/* LOP */ PVR_ROGUE_PDSINST_LOP_NONE, |
| 1181 |
/* SRC0 */ vertex_stream->instance_data ? input_register1 |
| 1182 |
: input_register0, |
| 1183 |
/* SRC1 */ input_register0, /* This won't be used in |
| 1184 |
* a shift operation. |
| 1185 |
*/ |
| 1186 |
/* SRC2 (Shift) */ shift_2s_comp, |
| 1187 |
/* DST */ temp); |
| 1188 |
|
| 1189 |
if (instance_data_with_base_instance) { |
| 1190 |
*buffer++ = |
| 1191 |
pvr_pds_inst_encode_add32(0, /* cc */ |
| 1192 |
0, /* ALNUM */ |
| 1193 |
0, /* SNA */ |
| 1194 |
base_instance_register, /* src0 |
| 1195 |
*/ |
| 1196 |
temp, /* src1 */ |
| 1197 |
temp /* dst */ |
| 1198 |
); |
| 1199 |
} |
| 1200 |
} else { |
| 1201 |
if (instance_data_with_base_instance) { |
| 1202 |
*buffer++ = |
| 1203 |
pvr_pds_inst_encode_add32(0, /* cc */ |
| 1204 |
0, /* ALNUM */ |
| 1205 |
0, /* SNA */ |
| 1206 |
base_instance_register, /* src0 |
| 1207 |
*/ |
| 1208 |
input_register1, /* src1 */ |
| 1209 |
temp /* dst */ |
| 1210 |
); |
| 1211 |
} else { |
| 1212 |
/* If the shift instruction doesn't happen, use the IR |
| 1213 |
* directly into the following MAD. |
| 1214 |
*/ |
| 1215 |
temp = vertex_stream->instance_data ? input_register1 |
| 1216 |
: input_register0; |
| 1217 |
} |
| 1218 |
} |
| 1219 |
} |
| 1220 |
} |
| 1221 |
|
| 1222 |
if (PVR_HAS_FEATURE(dev_info, pds_ddmadt)) { |
| 1223 |
if (vertex_stream->use_ddmadt) |
| 1224 |
ddmadt_enables |= (1 << stream); |
| 1225 |
} else { |
| 1226 |
if ((ddmadt_enables & (1 << stream)) != 0) { |
| 1227 |
/* Emulate what DDMADT does for range checking. */ |
| 1228 |
if (first_ddmadt) { |
| 1229 |
/* Get an 64 bits temp such that cmp current index with |
| 1230 |
* allowed vertex number can work. |
| 1231 |
*/ |
| 1232 |
index_temp64 = |
| 1233 |
pvr_pds_get_temps(&next_temp, 2, &temps_used); /* 64-bit |
| 1234 |
*/ |
| 1235 |
num_vertices_temp64 = |
| 1236 |
pvr_pds_get_temps(&next_temp, 2, &temps_used); /* 64-bit |
| 1237 |
*/ |
| 1238 |
|
| 1239 |
index_temp64 -= PVR_ROGUE_PDSINST_REGS32_TEMP32_LOWER; |
| 1240 |
num_vertices_temp64 -= PVR_ROGUE_PDSINST_REGS32_TEMP32_LOWER; |
| 1241 |
|
| 1242 |
code_size += 3; |
| 1243 |
current_p0 = true; |
| 1244 |
} |
| 1245 |
|
| 1246 |
code_size += (temp == pre_index_temp ? 1 : 2); |
| 1247 |
|
| 1248 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 1249 |
if (first_ddmadt) { |
| 1250 |
/* Set predicate to be P0. */ |
| 1251 |
*buffer++ = pvr_pds_encode_bra( |
| 1252 |
PVR_ROGUE_PDSINST_PREDICATE_KEEP, /* SRCCC |
| 1253 |
*/ |
| 1254 |
0, /* Neg */ |
| 1255 |
PVR_ROGUE_PDSINST_PREDICATE_P0, /* SETCC |
| 1256 |
*/ |
| 1257 |
1); /* Addr */ |
| 1258 |
|
| 1259 |
*buffer++ = |
| 1260 |
pvr_pds_inst_encode_limm(0, index_temp64 + 1, 0, 0); |
| 1261 |
*buffer++ = |
| 1262 |
pvr_pds_inst_encode_limm(0, num_vertices_temp64 + 1, 0, 0); |
| 1263 |
} |
| 1264 |
|
| 1265 |
if (temp != pre_index_temp) { |
| 1266 |
*buffer++ = pvr_pds_inst_encode_sftlp32( |
| 1267 |
/* IM */ 1, /* enable immediate. */ |
| 1268 |
/* cc */ 0, |
| 1269 |
/* LOP */ PVR_ROGUE_PDSINST_LOP_NONE, |
| 1270 |
/* SRC0 */ temp - PVR_ROGUE_PDSINST_REGS32_TEMP32_LOWER, |
| 1271 |
/* SRC1 */ 0, |
| 1272 |
/* SRC2 (Shift) */ 0, |
| 1273 |
/* DST */ index_temp64); |
| 1274 |
} |
| 1275 |
|
| 1276 |
*buffer++ = pvr_pds_inst_encode_sftlp32( |
| 1277 |
/* IM */ 1, /* enable immediate. */ |
| 1278 |
/* cc */ 0, |
| 1279 |
/* LOP */ PVR_ROGUE_PDSINST_LOP_OR, |
| 1280 |
/* SRC0 */ num_vertices_temp64 + 1, |
| 1281 |
/* SRC1 */ vertex_stream->num_vertices, |
| 1282 |
/* SRC2 (Shift) */ 0, |
| 1283 |
/* DST */ num_vertices_temp64); |
| 1284 |
} |
| 1285 |
|
| 1286 |
first_ddmadt = false; |
| 1287 |
|
| 1288 |
pre_index_temp = temp; |
| 1289 |
} |
| 1290 |
} |
| 1291 |
|
| 1292 |
/* Process the elements in the stream. */ |
| 1293 |
for (uint32_t element = 0; element < vertex_stream->num_elements; |
| 1294 |
element++) { |
| 1295 |
bool terminate = false; |
| 1296 |
|
| 1297 |
vertex_element = &vertex_stream->elements[element]; |
| 1298 |
/* Check if last DDMAD needs terminate or not. */ |
| 1299 |
if ((element == (vertex_stream->num_elements - 1)) && |
| 1300 |
(stream == last_stream_index)) { |
| 1301 |
terminate = !issue_empty_ddmad && !direct_writes_needed; |
| 1302 |
} |
| 1303 |
|
| 1304 |
/* Get a new set of constants for this element. */ |
| 1305 |
if (element) { |
| 1306 |
/* Get all 8 32 bit constants at once. */ |
| 1307 |
next_constant = |
| 1308 |
pvr_pds_get_constants(&next_stream_constant, 8, &data_size); |
| 1309 |
} |
| 1310 |
|
| 1311 |
dma_address_constant64 = next_constant + 4; |
| 1312 |
dma_control_constant64 = dma_address_constant64 + 2; |
| 1313 |
|
| 1314 |
if (vertex_element->component_size == 0) { |
| 1315 |
/* Standard DMA. |
| 1316 |
* |
| 1317 |
* Write the DMA transfer control words into the PDS data |
| 1318 |
* section. |
| 1319 |
* |
| 1320 |
* DMA Address is 40-bit. |
| 1321 |
*/ |
| 1322 |
|
| 1323 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 1324 |
uint32_t dma_control_word; |
| 1325 |
uint64_t dma_control_word64 = 0; |
| 1326 |
uint32_t dma_size; |
| 1327 |
|
| 1328 |
/* Write the address to the constant. */ |
| 1329 |
pvr_pds_write_dma_address(buffer, |
| 1330 |
dma_address_constant64, |
| 1331 |
vertex_stream->address + |
| 1332 |
(uint64_t)vertex_element->offset, |
| 1333 |
false, |
| 1334 |
dev_info); |
| 1335 |
{ |
| 1336 |
if (program->stream_patch_offsets) { |
| 1337 |
program |
| 1338 |
->stream_patch_offsets[program->num_stream_patches++] = |
| 1339 |
(stream << 16) | (dma_address_constant64 >> 1); |
| 1340 |
} |
| 1341 |
} |
| 1342 |
|
| 1343 |
/* Size is in bytes - round up to nearest 32 bit word. */ |
| 1344 |
dma_size = |
| 1345 |
(vertex_element->size + (1 << PVR_PDS_DWORD_SHIFT) - 1) >> |
| 1346 |
PVR_PDS_DWORD_SHIFT; |
| 1347 |
|
| 1348 |
assert(dma_size <= PVR_ROGUE_PDSINST_DDMAD_FIELDS_BSIZE_UPPER); |
| 1349 |
|
| 1350 |
/* Set up the dma transfer control word. */ |
| 1351 |
dma_control_word = |
| 1352 |
dma_size << PVR_ROGUE_PDSINST_DDMAD_FIELDS_SRC3_BSIZE_SHIFT; |
| 1353 |
|
| 1354 |
dma_control_word |= |
| 1355 |
vertex_element->reg |
| 1356 |
<< PVR_ROGUE_PDSINST_DDMAD_FIELDS_SRC3_AO_SHIFT; |
| 1357 |
|
| 1358 |
dma_control_word |= |
| 1359 |
PVR_ROGUE_PDSINST_DDMAD_FIELDS_SRC3_DEST_UNIFIED_STORE | |
| 1360 |
PVR_ROGUE_PDSINST_DDMAD_FIELDS_SRC3_CMODE_CACHED; |
| 1361 |
|
| 1362 |
if (PVR_HAS_FEATURE(dev_info, pds_ddmadt)) { |
| 1363 |
if ((ddmadt_enables & (1 << stream)) != 0) { |
| 1364 |
assert( |
| 1365 |
((((uint64_t)vertex_stream->buffer_size_in_bytes |
| 1366 |
<< PVR_ROGUE_PDSINST_DDMAD_FIELDS_SRC3_MSIZE_SHIFT) & |
| 1367 |
~PVR_ROGUE_PDSINST_DDMAD_FIELDS_SRC3_MSIZE_CLRMSK) >> |
| 1368 |
PVR_ROGUE_PDSINST_DDMAD_FIELDS_SRC3_MSIZE_SHIFT) == |
| 1369 |
(uint64_t)vertex_stream->buffer_size_in_bytes); |
| 1370 |
dma_control_word64 = |
| 1371 |
(PVR_ROGUE_PDSINST_DDMAD_FIELDS_SRC3_TEST_EN | |
| 1372 |
(((uint64_t)vertex_stream->buffer_size_in_bytes |
| 1373 |
<< PVR_ROGUE_PDSINST_DDMAD_FIELDS_SRC3_MSIZE_SHIFT) & |
| 1374 |
~PVR_ROGUE_PDSINST_DDMAD_FIELDS_SRC3_MSIZE_CLRMSK)); |
| 1375 |
} |
| 1376 |
} |
| 1377 |
/* If this is the last dma then also set the last flag. */ |
| 1378 |
if (terminate) { |
| 1379 |
dma_control_word |= |
| 1380 |
PVR_ROGUE_PDSINST_DDMAD_FIELDS_SRC3_LAST_EN; |
| 1381 |
} |
| 1382 |
|
| 1383 |
/* Write the 32-Bit SRC3 word to a 64-bit constant as per |
| 1384 |
* spec. |
| 1385 |
*/ |
| 1386 |
pvr_pds_write_wide_constant(buffer, |
| 1387 |
dma_control_constant64, |
| 1388 |
dma_control_word64 | |
| 1389 |
(uint64_t)dma_control_word); |
| 1390 |
} |
| 1391 |
|
| 1392 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 1393 |
if (!PVR_HAS_FEATURE(dev_info, pds_ddmadt)) { |
| 1394 |
if ((ddmadt_enables & (1 << stream)) != 0) { |
| 1395 |
*buffer++ = pvr_pds_inst_encode_cmp( |
| 1396 |
0, /* cc enable */ |
| 1397 |
PVR_ROGUE_PDSINST_COP_LT, /* Operation */ |
| 1398 |
index_temp64 >> 1, /* SRC0 (REGS64TP) */ |
| 1399 |
(num_vertices_temp64 >> 1) + |
| 1400 |
PVR_ROGUE_PDSINST_REGS64_TEMP64_LOWER); /* SRC1 |
| 1401 |
(REGS64) |
| 1402 |
*/ |
| 1403 |
} |
| 1404 |
} |
| 1405 |
/* Multiply by the vertex stream stride and add the base |
| 1406 |
* followed by a DOUTD. |
| 1407 |
* |
| 1408 |
* dmad32 (C0 * T0) + C1, C2 |
| 1409 |
* src0 = stride src1 = index src2 = baseaddr src3 = |
| 1410 |
* doutd part |
| 1411 |
*/ |
| 1412 |
|
| 1413 |
uint32_t cc; |
| 1414 |
if (PVR_HAS_FEATURE(dev_info, pds_ddmadt)) |
| 1415 |
cc = 0; |
| 1416 |
else |
| 1417 |
cc = (ddmadt_enables & (1 << stream)) != 0 ? 1 : 0; |
| 1418 |
|
| 1419 |
*buffer++ = pvr_pds_inst_encode_ddmad( |
| 1420 |
/* cc */ cc, |
| 1421 |
/* END */ 0, |
| 1422 |
/* SRC0 */ stride_constant32, /* Stride 32-bit*/ |
| 1423 |
/* SRC1 */ temp, /* Index 32-bit*/ |
| 1424 |
/* SRC2 64-bit */ dma_address_constant64 >> 1, /* Stream |
| 1425 |
* Address |
| 1426 |
* + |
| 1427 |
* Offset |
| 1428 |
*/ |
| 1429 |
/* SRC3 64-bit */ dma_control_constant64 >> 1 /* DMA |
| 1430 |
* Transfer |
| 1431 |
* Control |
| 1432 |
* Word. |
| 1433 |
*/ |
| 1434 |
); |
| 1435 |
} |
| 1436 |
|
| 1437 |
if ((!PVR_HAS_FEATURE(dev_info, pds_ddmadt)) && |
| 1438 |
((ddmadt_enables & (1 << stream)) != 0)) { |
| 1439 |
code_size += 1; |
| 1440 |
} |
| 1441 |
code_size += 1; |
| 1442 |
} else { |
| 1443 |
/* Repeat DMA. |
| 1444 |
* |
| 1445 |
* Write the DMA transfer control words into the PDS data |
| 1446 |
* section. |
| 1447 |
* |
| 1448 |
* DMA address is 40-bit. |
| 1449 |
*/ |
| 1450 |
|
| 1451 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 1452 |
uint32_t dma_control_word; |
| 1453 |
|
| 1454 |
/* Write the address to the constant. */ |
| 1455 |
pvr_pds_write_dma_address(buffer, |
| 1456 |
dma_address_constant64, |
| 1457 |
vertex_stream->address + |
| 1458 |
(uint64_t)vertex_element->offset, |
| 1459 |
false, |
| 1460 |
dev_info); |
| 1461 |
|
| 1462 |
/* Set up the DMA transfer control word. */ |
| 1463 |
dma_control_word = |
| 1464 |
vertex_element->size |
| 1465 |
<< PVR_ROGUE_PDSINST_DDMAD_FIELDS_SRC3_BSIZE_SHIFT; |
| 1466 |
|
| 1467 |
dma_control_word |= |
| 1468 |
vertex_element->reg |
| 1469 |
<< PVR_ROGUE_PDSINST_DDMAD_FIELDS_SRC3_AO_SHIFT; |
| 1470 |
|
| 1471 |
switch (vertex_element->component_size) { |
| 1472 |
case 4: { |
| 1473 |
dma_control_word |= |
| 1474 |
PVR_ROGUE_PDSINST_DDMAD_FIELDS_SRC3_WORDSIZE_FOUR; |
| 1475 |
break; |
| 1476 |
} |
| 1477 |
case 3: { |
| 1478 |
dma_control_word |= |
| 1479 |
PVR_ROGUE_PDSINST_DDMAD_FIELDS_SRC3_WORDSIZE_THREE; |
| 1480 |
break; |
| 1481 |
} |
| 1482 |
case 2: { |
| 1483 |
dma_control_word |= |
| 1484 |
PVR_ROGUE_PDSINST_DDMAD_FIELDS_SRC3_WORDSIZE_TWO; |
| 1485 |
break; |
| 1486 |
} |
| 1487 |
default: { |
| 1488 |
dma_control_word |= |
| 1489 |
PVR_ROGUE_PDSINST_DDMAD_FIELDS_SRC3_WORDSIZE_ONE; |
| 1490 |
break; |
| 1491 |
} |
| 1492 |
} |
| 1493 |
|
| 1494 |
dma_control_word |= |
| 1495 |
PVR_ROGUE_PDSINST_DDMAD_FIELDS_SRC3_REPEAT_REPEAT; |
| 1496 |
|
| 1497 |
dma_control_word |= |
| 1498 |
PVR_ROGUE_PDSINST_DDMAD_FIELDS_SRC3_DEST_UNIFIED_STORE | |
| 1499 |
PVR_ROGUE_PDSINST_DDMAD_FIELDS_SRC3_CMODE_CACHED; |
| 1500 |
|
| 1501 |
/* If this is the last dma then also set the last flag. */ |
| 1502 |
if (terminate) { |
| 1503 |
dma_control_word |= |
| 1504 |
PVR_ROGUE_PDSINST_DDMAD_FIELDS_SRC3_LAST_EN; |
| 1505 |
} |
| 1506 |
|
| 1507 |
/* Write the 32-Bit SRC3 word to a 64-bit constant as per |
| 1508 |
* spec. |
| 1509 |
*/ |
| 1510 |
pvr_pds_write_wide_constant(buffer, |
| 1511 |
dma_control_constant64, |
| 1512 |
(uint64_t)dma_control_word); |
| 1513 |
} |
| 1514 |
|
| 1515 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 1516 |
/* Multiply by the vertex stream stride and add the base |
| 1517 |
* followed by a DOUTD. |
| 1518 |
* |
| 1519 |
* dmad32 (C0 * T0) + C1, C2 |
| 1520 |
* src0 = stride src1 = index src2 = baseaddr src3 = |
| 1521 |
* doutd part |
| 1522 |
*/ |
| 1523 |
*buffer++ = pvr_pds_inst_encode_ddmad( |
| 1524 |
/* cc */ 0, |
| 1525 |
/* END */ 0, |
| 1526 |
/* SRC0 */ stride_constant32, /* Stride 32-bit*/ |
| 1527 |
/* SRC1 */ temp, /* Index 32-bit*/ |
| 1528 |
/* SRC2 64-bit */ dma_address_constant64 >> 1, /* Stream |
| 1529 |
* Address |
| 1530 |
* + |
| 1531 |
* Offset. |
| 1532 |
*/ |
| 1533 |
/* SRC3 64-bit */ dma_control_constant64 >> 1 /* DMA |
| 1534 |
* Transfer |
| 1535 |
* Control |
| 1536 |
* Word. |
| 1537 |
*/ |
| 1538 |
); |
| 1539 |
} |
| 1540 |
|
| 1541 |
code_size += 1; |
| 1542 |
} /* End of repeat DMA. */ |
| 1543 |
} /* Element loop */ |
| 1544 |
} /* Stream loop */ |
| 1545 |
|
| 1546 |
if (issue_empty_ddmad) { |
| 1547 |
/* Issue an empty last DDMAD, always executed. */ |
| 1548 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 1549 |
pvr_pds_write_wide_constant( |
| 1550 |
buffer, |
| 1551 |
empty_dma_control_constant64, |
| 1552 |
PVR_ROGUE_PDSINST_DDMAD_FIELDS_SRC3_LAST_EN); |
| 1553 |
} |
| 1554 |
|
| 1555 |
code_size += 1; |
| 1556 |
|
| 1557 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 1558 |
*buffer++ = pvr_pds_inst_encode_ddmad( |
| 1559 |
/* cc */ 0, |
| 1560 |
/* END */ 0, |
| 1561 |
/* SRC0 */ stride_constant32, /* Stride 32-bit*/ |
| 1562 |
/* SRC1 */ temp, /* Index 32-bit*/ |
| 1563 |
/* SRC2 64-bit */ dma_address_constant64 >> 1, /* Stream |
| 1564 |
*Address + |
| 1565 |
*Offset. |
| 1566 |
*/ |
| 1567 |
/* SRC3 64-bit */ empty_dma_control_constant64 >> 1 /* DMA |
| 1568 |
* Transfer |
| 1569 |
* Control |
| 1570 |
* Word. |
| 1571 |
*/ |
| 1572 |
); |
| 1573 |
} |
| 1574 |
} |
| 1575 |
|
| 1576 |
if (!PVR_HAS_FEATURE(dev_info, pds_ddmadt)) { |
| 1577 |
if (current_p0) { |
| 1578 |
code_size += 1; |
| 1579 |
|
| 1580 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 1581 |
/* Revert predicate back to IF0 which is required by DOUTU. */ |
| 1582 |
*buffer++ = |
| 1583 |
pvr_pds_encode_bra(PVR_ROGUE_PDSINST_PREDICATE_KEEP, /* SRCCC |
| 1584 |
*/ |
| 1585 |
0, /* Neg */ |
| 1586 |
PVR_ROGUE_PDSINST_PREDICATE_IF0, /* SETCC |
| 1587 |
*/ |
| 1588 |
1); /* Addr */ |
| 1589 |
} |
| 1590 |
} |
| 1591 |
} |
| 1592 |
/* Send VertexID if requested. */ |
| 1593 |
if (program->iterate_vtx_id) { |
| 1594 |
if (program->draw_indirect) { |
| 1595 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 1596 |
*buffer++ = pvr_pds_inst_encode_add32( |
| 1597 |
/* cc */ 0x0, |
| 1598 |
/* ALUM */ 0, /* Unsigned */ |
| 1599 |
/* SNA */ 1, /* Minus */ |
| 1600 |
/* SRC0 32b */ input_register0, /* vertexID */ |
| 1601 |
/* SRC1 32b */ PVR_ROGUE_PDSINST_REGS32_PTEMP32_LOWER, /* base |
| 1602 |
* vertexID. |
| 1603 |
*/ |
| 1604 |
/* DST 32b */ input_register0); |
| 1605 |
} |
| 1606 |
|
| 1607 |
code_size += 1; |
| 1608 |
} |
| 1609 |
|
| 1610 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 1611 |
uint32_t doutw = pvr_pds_encode_doutw_src1( |
| 1612 |
program->vtx_id_register, |
| 1613 |
PVR_PDS_DOUTW_LOWER32, |
| 1614 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_UNIFIED_STORE, |
| 1615 |
false, |
| 1616 |
dev_info); |
| 1617 |
|
| 1618 |
if (!program->iterate_instance_id && !program->iterate_remap_id) |
| 1619 |
doutw |= PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_LAST_EN; |
| 1620 |
|
| 1621 |
pvr_pds_write_constant32(buffer, |
| 1622 |
vertex_id_control_word_const32, |
| 1623 |
doutw); |
| 1624 |
} else if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 1625 |
*buffer++ = pvr_pds_encode_doutw64( |
| 1626 |
/* cc */ 0, |
| 1627 |
/* END */ 0, |
| 1628 |
/* SRC1 */ vertex_id_control_word_const32, /* DOUTW 32-bit Src1 |
| 1629 |
*/ |
| 1630 |
/* SRC0 */ input_register0 >> 1); /* DOUTW 64-bit Src0 */ |
| 1631 |
} |
| 1632 |
|
| 1633 |
code_size += 1; |
| 1634 |
} |
| 1635 |
|
| 1636 |
/* Send InstanceID if requested. */ |
| 1637 |
if (program->iterate_instance_id) { |
| 1638 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 1639 |
uint32_t doutw = pvr_pds_encode_doutw_src1( |
| 1640 |
program->instance_id_register, |
| 1641 |
PVR_PDS_DOUTW_UPPER32, |
| 1642 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_UNIFIED_STORE, |
| 1643 |
true, |
| 1644 |
dev_info); |
| 1645 |
|
| 1646 |
if (!program->iterate_remap_id) |
| 1647 |
doutw |= PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_LAST_EN; |
| 1648 |
|
| 1649 |
pvr_pds_write_constant32(buffer, |
| 1650 |
instance_id_control_word_const32, |
| 1651 |
doutw); |
| 1652 |
} else if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 1653 |
*buffer++ = pvr_pds_encode_doutw64( |
| 1654 |
/* cc */ 0, |
| 1655 |
/* END */ 0, |
| 1656 |
/* SRC1 */ instance_id_control_word_const32, /* DOUTW 32-bit Src1 */ |
| 1657 |
/* SRC0 */ input_register1 >> 1); /* DOUTW 64-bit Src0 */ |
| 1658 |
} |
| 1659 |
|
| 1660 |
code_size += 1; |
| 1661 |
} |
| 1662 |
|
| 1663 |
/* Send remapped index number to vi0. */ |
| 1664 |
if (program->iterate_remap_id) { |
| 1665 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 1666 |
uint32_t doutw = pvr_pds_encode_doutw_src1( |
| 1667 |
0 /* vi0 */, |
| 1668 |
PVR_PDS_DOUTW_LOWER32, |
| 1669 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_UNIFIED_STORE | |
| 1670 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_LAST_EN, |
| 1671 |
false, |
| 1672 |
dev_info); |
| 1673 |
|
| 1674 |
pvr_pds_write_constant64(buffer, |
| 1675 |
geometry_id_control_word_const64, |
| 1676 |
doutw, |
| 1677 |
0); |
| 1678 |
} else if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 1679 |
*buffer++ = pvr_pds_encode_doutw64( |
| 1680 |
/* cc */ 0, |
| 1681 |
/* END */ 0, |
| 1682 |
/* SRC1 */ geometry_id_control_word_const64, /* DOUTW 32-bit |
| 1683 |
* Src1 |
| 1684 |
*/ |
| 1685 |
/* SRC0 */ input_register2 >> 1); /* DOUTW 64-bit Src0 */ |
| 1686 |
} |
| 1687 |
|
| 1688 |
code_size += 1; |
| 1689 |
} |
| 1690 |
|
| 1691 |
/* Copy the USC task control words to constants. */ |
| 1692 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 1693 |
pvr_pds_write_wide_constant(buffer, |
| 1694 |
usc_control_constant64, |
| 1695 |
program->usc_task_control.src0); /* 64-bit |
| 1696 |
* Src0 |
| 1697 |
*/ |
| 1698 |
if (program->stream_patch_offsets) { |
| 1699 |
/* USC TaskControl is always the first patch. */ |
| 1700 |
program->stream_patch_offsets[0] = usc_control_constant64 >> 1; |
| 1701 |
} |
| 1702 |
} |
| 1703 |
|
| 1704 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 1705 |
/* Conditionally (if last in task) issue the task to the USC |
| 1706 |
* (if0) DOUTU src1=USC Code Base address, src2=DOUTU word 2. |
| 1707 |
*/ |
| 1708 |
|
| 1709 |
*buffer++ = pvr_pds_encode_doutu( |
| 1710 |
/* cc */ 1, |
| 1711 |
/* END */ 1, |
| 1712 |
/* SRC0 */ usc_control_constant64 >> 1); /* DOUTU 64-bit Src0 */ |
| 1713 |
|
| 1714 |
/* End the program if the Dout did not already end it. */ |
| 1715 |
*buffer++ = pvr_pds_inst_encode_halt(0); |
| 1716 |
} |
| 1717 |
|
| 1718 |
code_size += 2; |
| 1719 |
|
| 1720 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 1721 |
/* Set the data segment pointer and ensure we return 1 past the buffer |
| 1722 |
* ptr. |
| 1723 |
*/ |
| 1724 |
program->data_segment = buffer; |
| 1725 |
|
| 1726 |
buffer += consts_size; |
| 1727 |
} |
| 1728 |
|
| 1729 |
program->temps_used = temps_used; |
| 1730 |
program->data_size = consts_size; |
| 1731 |
program->code_size = code_size; |
| 1732 |
program->ddmadt_enables = ddmadt_enables; |
| 1733 |
if (!PVR_HAS_FEATURE(dev_info, pds_ddmadt)) |
| 1734 |
program->skip_stream_flag = skip_stream_flag; |
| 1735 |
|
| 1736 |
return buffer; |
| 1737 |
} |
| 1738 |
|
| 1739 |
/** |
| 1740 |
* Generates a PDS program to load USC compute shader global/local/workgroup |
| 1741 |
* sizes/ids and then a DOUTU to execute the USC. |
| 1742 |
* |
| 1743 |
* \param program Pointer to description of the program that should be |
| 1744 |
* generated. |
| 1745 |
* \param buffer Pointer to buffer that receives the output of this function. |
| 1746 |
* This will be either the data segment, or the code depending on |
| 1747 |
* gen_mode. |
| 1748 |
* \param gen_mode Which part to generate, either data segment or code segment. |
| 1749 |
* If PDS_GENERATE_SIZES is specified, nothing is written, but |
| 1750 |
* size information in program is updated. |
| 1751 |
* \param dev_info PVR device info struct. |
| 1752 |
* \returns Pointer to just beyond the buffer for the data - i.e. the value of |
| 1753 |
* the buffer after writing its contents. |
| 1754 |
*/ |
| 1755 |
uint32_t * |
| 1756 |
pvr_pds_compute_shader(struct pvr_pds_compute_shader_program *restrict program, |
| 1757 |
uint32_t *restrict buffer, |
| 1758 |
enum pvr_pds_generate_mode gen_mode, |
| 1759 |
const struct pvr_device_info *dev_info) |
| 1760 |
{ |
| 1761 |
uint32_t usc_control_constant64; |
| 1762 |
uint32_t usc_control_constant64_coeff_update = 0; |
| 1763 |
uint32_t zero_constant64 = 0; |
| 1764 |
|
| 1765 |
uint32_t data_size = 0; |
| 1766 |
uint32_t code_size = 0; |
| 1767 |
uint32_t temps_used = 0; |
| 1768 |
uint32_t doutw = 0; |
| 1769 |
uint32_t doutd = 0; |
| 1770 |
|
| 1771 |
uint32_t barrier_ctrl_word = 0; |
| 1772 |
uint32_t barrier_ctrl_word2 = 0; |
| 1773 |
|
| 1774 |
/* Even though there are 3 IDs for local and global we only need max one |
| 1775 |
* DOUTW for local, and two for global. |
| 1776 |
*/ |
| 1777 |
uint32_t work_group_id_ctrl_words[2] = { 0 }; |
| 1778 |
uint32_t num_work_groups_ctrl_words[3] = { 0 }; |
| 1779 |
uint32_t local_id_ctrl_word = 0; |
| 1780 |
uint32_t local_input_register; |
| 1781 |
|
| 1782 |
/* For the constant value to load into ptemp (SW fence). */ |
| 1783 |
uint64_t predicate_ld_src0_constant = 0; |
| 1784 |
uint32_t cond_render_negate_constant = 0; |
| 1785 |
|
| 1786 |
uint32_t cond_render_pred_temp; |
| 1787 |
uint32_t cond_render_negate_temp; |
| 1788 |
|
| 1789 |
/* 2x 64 bit registers that will mask out the Predicate load. */ |
| 1790 |
uint32_t cond_render_pred_mask_constant = 0; |
| 1791 |
|
| 1792 |
#if MESA_DEBUG |
| 1793 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 1794 |
for (uint32_t j = 0; j < program->data_size; j++) |
| 1795 |
buffer[j] = 0xDEADBEEF; |
| 1796 |
} |
| 1797 |
#endif |
| 1798 |
|
| 1799 |
/* All the compute input registers are in temps. */ |
| 1800 |
temps_used += PVR_PDS_NUM_COMPUTE_INPUT_REGS; |
| 1801 |
|
| 1802 |
uint32_t next_temp = PVR_PDS_TEMPS_BLOCK_BASE + temps_used; |
| 1803 |
|
| 1804 |
uint32_t next_constant = PVR_PDS_CONSTANTS_BLOCK_BASE; |
| 1805 |
|
| 1806 |
const bool has_local_input_regs = |
| 1807 |
(program->local_input_regs[0] != PVR_PDS_REG_UNUSED) || |
| 1808 |
(program->local_input_regs[1] != PVR_PDS_REG_UNUSED) || |
| 1809 |
(program->local_input_regs[2] != PVR_PDS_REG_UNUSED); |
| 1810 |
|
| 1811 |
const bool has_local_input_reg[3] = { |
| 1812 |
[0] = program->local_input_regs[0] != PVR_PDS_REG_UNUSED, |
| 1813 |
[1] = program->local_input_regs[1] != PVR_PDS_REG_UNUSED, |
| 1814 |
[2] = program->local_input_regs[2] != PVR_PDS_REG_UNUSED, |
| 1815 |
}; |
| 1816 |
|
| 1817 |
const bool has_work_group_input_regs = |
| 1818 |
(program->work_group_input_regs[0] != PVR_PDS_REG_UNUSED) || |
| 1819 |
(program->work_group_input_regs[1] != PVR_PDS_REG_UNUSED) || |
| 1820 |
(program->work_group_input_regs[2] != PVR_PDS_REG_UNUSED); |
| 1821 |
|
| 1822 |
const bool has_work_group_input_reg[3] = { |
| 1823 |
[0] = program->work_group_input_regs[0] != PVR_PDS_REG_UNUSED, |
| 1824 |
[1] = program->work_group_input_regs[1] != PVR_PDS_REG_UNUSED, |
| 1825 |
[2] = program->work_group_input_regs[2] != PVR_PDS_REG_UNUSED, |
| 1826 |
}; |
| 1827 |
|
| 1828 |
const bool has_num_work_groups_regs = |
| 1829 |
(program->num_work_groups_regs[0] != PVR_PDS_REG_UNUSED) || |
| 1830 |
(program->num_work_groups_regs[1] != PVR_PDS_REG_UNUSED) || |
| 1831 |
(program->num_work_groups_regs[2] != PVR_PDS_REG_UNUSED); |
| 1832 |
|
| 1833 |
const bool has_num_work_groups_reg[3] = { |
| 1834 |
[0] = program->num_work_groups_regs[0] != PVR_PDS_REG_UNUSED, |
| 1835 |
[1] = program->num_work_groups_regs[1] != PVR_PDS_REG_UNUSED, |
| 1836 |
[2] = program->num_work_groups_regs[2] != PVR_PDS_REG_UNUSED, |
| 1837 |
}; |
| 1838 |
|
| 1839 |
const bool has_barrier_coefficient = program->barrier_coefficient != |
| 1840 |
PVR_PDS_REG_UNUSED; |
| 1841 |
|
| 1842 |
if (program->kick_usc) { |
| 1843 |
/* Copy the USC task control words to constants. */ |
| 1844 |
usc_control_constant64 = |
| 1845 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 1846 |
} |
| 1847 |
|
| 1848 |
if (program->has_coefficient_update_task) { |
| 1849 |
usc_control_constant64_coeff_update = |
| 1850 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 1851 |
} |
| 1852 |
|
| 1853 |
if (program->conditional_render) { |
| 1854 |
predicate_ld_src0_constant = |
| 1855 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 1856 |
cond_render_negate_constant = |
| 1857 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 1858 |
cond_render_pred_mask_constant = |
| 1859 |
pvr_pds_get_constants(&next_constant, 4, &data_size); |
| 1860 |
|
| 1861 |
/* LD will load a 64 bit value. */ |
| 1862 |
cond_render_pred_temp = pvr_pds_get_temps(&next_temp, 4, &temps_used); |
| 1863 |
cond_render_negate_temp = pvr_pds_get_temps(&next_temp, 2, &temps_used); |
| 1864 |
|
| 1865 |
program->cond_render_const_offset_in_dwords = predicate_ld_src0_constant; |
| 1866 |
program->cond_render_pred_temp = cond_render_pred_temp; |
| 1867 |
} |
| 1868 |
|
| 1869 |
if (has_barrier_coefficient || program->clear_pds_barrier || |
| 1870 |
(program->kick_usc && program->conditional_render)) { |
| 1871 |
zero_constant64 = pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 1872 |
} |
| 1873 |
|
| 1874 |
if (has_barrier_coefficient) { |
| 1875 |
barrier_ctrl_word = pvr_pds_get_constants(&next_constant, 1, &data_size); |
| 1876 |
if (PVR_HAS_QUIRK(dev_info, 51210)) { |
| 1877 |
barrier_ctrl_word2 = |
| 1878 |
pvr_pds_get_constants(&next_constant, 1, &data_size); |
| 1879 |
} |
| 1880 |
} |
| 1881 |
|
| 1882 |
/* For DOUTW */ |
| 1883 |
if (has_work_group_input_reg[0] || has_work_group_input_reg[1]) { |
| 1884 |
work_group_id_ctrl_words[0] = |
| 1885 |
pvr_pds_get_constants(&next_constant, 1, &data_size); |
| 1886 |
} |
| 1887 |
|
| 1888 |
if (has_work_group_input_reg[2]) { |
| 1889 |
work_group_id_ctrl_words[1] = |
| 1890 |
pvr_pds_get_constants(&next_constant, 1, &data_size); |
| 1891 |
} |
| 1892 |
|
| 1893 |
/* For DOUTW */ |
| 1894 |
if (has_num_work_groups_reg[0] || has_num_work_groups_reg[1]) { |
| 1895 |
num_work_groups_ctrl_words[0] = |
| 1896 |
pvr_pds_get_constants(&next_constant, 1, &data_size); |
| 1897 |
} |
| 1898 |
|
| 1899 |
if (has_num_work_groups_reg[2]) { |
| 1900 |
num_work_groups_ctrl_words[1] = |
| 1901 |
pvr_pds_get_constants(&next_constant, 1, &data_size); |
| 1902 |
} |
| 1903 |
|
| 1904 |
if (has_num_work_groups_regs) { |
| 1905 |
num_work_groups_ctrl_words[2] = |
| 1906 |
pvr_pds_get_constants(&next_constant, 1, &data_size); |
| 1907 |
program->num_workgroups_indirect_src_dma = num_work_groups_ctrl_words[2]; |
| 1908 |
} |
| 1909 |
|
| 1910 |
/* For DOUTW */ |
| 1911 |
if (has_local_input_regs) { |
| 1912 |
local_id_ctrl_word = pvr_pds_get_constants(&next_constant, 1, &data_size); |
| 1913 |
} |
| 1914 |
|
| 1915 |
/* Patch constants. */ |
| 1916 |
for (uint32_t wg_comp = 0; wg_comp < 3; ++wg_comp) { |
| 1917 |
if (has_work_group_input_reg[wg_comp]) { |
| 1918 |
program->base_workgroup_constant_offset_in_dwords[wg_comp] = |
| 1919 |
pvr_pds_get_constants(&next_constant, 1, &data_size); |
| 1920 |
} |
| 1921 |
} |
| 1922 |
|
| 1923 |
if (has_num_work_groups_regs) { |
| 1924 |
/* Ensure 64-bit alignment. */ |
| 1925 |
program->num_workgroups_constant_offset_in_dwords[0] = |
| 1926 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 1927 |
program->num_workgroups_constant_offset_in_dwords[1] = |
| 1928 |
program->num_workgroups_constant_offset_in_dwords[0]; |
| 1929 |
program->num_workgroups_constant_offset_in_dwords[2] = |
| 1930 |
pvr_pds_get_constants(&next_constant, 1, &data_size); |
| 1931 |
|
| 1932 |
program->num_workgroups_indirect_src = |
| 1933 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 1934 |
} |
| 1935 |
|
| 1936 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 1937 |
if (program->kick_usc) { |
| 1938 |
/* Src0 for DOUTU */ |
| 1939 |
pvr_pds_write_wide_constant(buffer, |
| 1940 |
usc_control_constant64, |
| 1941 |
program->usc_task_control.src0); /* 64-bit |
| 1942 |
* Src0. |
| 1943 |
*/ |
| 1944 |
} |
| 1945 |
|
| 1946 |
if (program->has_coefficient_update_task) { |
| 1947 |
/* Src0 for DOUTU. */ |
| 1948 |
pvr_pds_write_wide_constant( |
| 1949 |
buffer, |
| 1950 |
usc_control_constant64_coeff_update, |
| 1951 |
program->usc_task_control_coeff_update.src0); /* 64-bit Src0 */ |
| 1952 |
} |
| 1953 |
|
| 1954 |
if (has_barrier_coefficient || program->clear_pds_barrier || |
| 1955 |
(program->kick_usc && program->conditional_render)) { |
| 1956 |
pvr_pds_write_wide_constant(buffer, zero_constant64, 0); /* 64-bit |
| 1957 |
* Src0 |
| 1958 |
*/ |
| 1959 |
} |
| 1960 |
|
| 1961 |
if (has_barrier_coefficient) { |
| 1962 |
if (PVR_HAS_QUIRK(dev_info, 51210)) { |
| 1963 |
/* Write the constant for the coefficient register write. */ |
| 1964 |
doutw = pvr_pds_encode_doutw_src1( |
| 1965 |
program->barrier_coefficient + 4, |
| 1966 |
PVR_PDS_DOUTW_LOWER64, |
| 1967 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_COMMON_STORE, |
| 1968 |
true, |
| 1969 |
dev_info); |
| 1970 |
pvr_pds_write_constant32(buffer, barrier_ctrl_word2, doutw); |
| 1971 |
} |
| 1972 |
/* Write the constant for the coefficient register write. */ |
| 1973 |
doutw = pvr_pds_encode_doutw_src1( |
| 1974 |
program->barrier_coefficient, |
| 1975 |
PVR_PDS_DOUTW_LOWER64, |
| 1976 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_COMMON_STORE, |
| 1977 |
true, |
| 1978 |
dev_info); |
| 1979 |
|
| 1980 |
/* Check whether the barrier is going to be the last DOUTW done by |
| 1981 |
* the coefficient sync task. |
| 1982 |
*/ |
| 1983 |
if (!has_work_group_input_regs && !has_num_work_groups_regs) |
| 1984 |
doutw |= PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_LAST_EN; |
| 1985 |
|
| 1986 |
pvr_pds_write_constant32(buffer, barrier_ctrl_word, doutw); |
| 1987 |
} |
| 1988 |
|
| 1989 |
/**/ |
| 1990 |
|
| 1991 |
/* If we want work-group id X, see if we also want work-group id Y. */ |
| 1992 |
if (has_work_group_input_reg[0] && has_work_group_input_reg[1]) { |
| 1993 |
/* Make sure we are going to DOUTW them into adjacent registers |
| 1994 |
* otherwise we can't do it in one. |
| 1995 |
*/ |
| 1996 |
assert(program->work_group_input_regs[1] == |
| 1997 |
(program->work_group_input_regs[0] + 1)); |
| 1998 |
|
| 1999 |
doutw = pvr_pds_encode_doutw_src1( |
| 2000 |
program->work_group_input_regs[0], |
| 2001 |
PVR_PDS_DOUTW_LOWER64, |
| 2002 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_COMMON_STORE, |
| 2003 |
true, |
| 2004 |
dev_info); |
| 2005 |
|
| 2006 |
/* If we don't want the Z work-group id then this is the last one. |
| 2007 |
*/ |
| 2008 |
if (!has_work_group_input_reg[2] && !has_num_work_groups_regs) |
| 2009 |
doutw |= PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_LAST_EN; |
| 2010 |
|
| 2011 |
pvr_pds_write_constant32(buffer, work_group_id_ctrl_words[0], doutw); |
| 2012 |
} |
| 2013 |
/* If we only want one of X or Y then handle them separately. */ |
| 2014 |
else { |
| 2015 |
if (has_work_group_input_reg[0]) { |
| 2016 |
doutw = pvr_pds_encode_doutw_src1( |
| 2017 |
program->work_group_input_regs[0], |
| 2018 |
PVR_PDS_DOUTW_LOWER32, |
| 2019 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_COMMON_STORE, |
| 2020 |
true, |
| 2021 |
dev_info); |
| 2022 |
|
| 2023 |
/* If we don't want the Z work-group id then this is the last |
| 2024 |
* one. |
| 2025 |
*/ |
| 2026 |
if (!has_work_group_input_reg[2] && !has_num_work_groups_regs) |
| 2027 |
doutw |= PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_LAST_EN; |
| 2028 |
|
| 2029 |
pvr_pds_write_constant32(buffer, |
| 2030 |
work_group_id_ctrl_words[0], |
| 2031 |
doutw); |
| 2032 |
} else if (has_work_group_input_reg[1]) { |
| 2033 |
doutw = pvr_pds_encode_doutw_src1( |
| 2034 |
program->work_group_input_regs[1], |
| 2035 |
PVR_PDS_DOUTW_UPPER32, |
| 2036 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_COMMON_STORE, |
| 2037 |
true, |
| 2038 |
dev_info); |
| 2039 |
|
| 2040 |
/* If we don't want the Z work-group id then this is the last |
| 2041 |
* one. |
| 2042 |
*/ |
| 2043 |
if (!has_work_group_input_reg[2] && !has_num_work_groups_regs) |
| 2044 |
doutw |= PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_LAST_EN; |
| 2045 |
|
| 2046 |
pvr_pds_write_constant32(buffer, |
| 2047 |
work_group_id_ctrl_words[0], |
| 2048 |
doutw); |
| 2049 |
} |
| 2050 |
} |
| 2051 |
|
| 2052 |
/* Handle work-group id Z. */ |
| 2053 |
if (has_work_group_input_reg[2]) { |
| 2054 |
doutw = pvr_pds_encode_doutw_src1( |
| 2055 |
program->work_group_input_regs[2], |
| 2056 |
PVR_PDS_DOUTW_UPPER32, |
| 2057 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_COMMON_STORE, |
| 2058 |
true, |
| 2059 |
dev_info); |
| 2060 |
|
| 2061 |
if (!has_num_work_groups_regs) |
| 2062 |
doutw |= PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_LAST_EN; |
| 2063 |
|
| 2064 |
pvr_pds_write_constant32(buffer, work_group_id_ctrl_words[1], doutw); |
| 2065 |
} |
| 2066 |
|
| 2067 |
/**/ |
| 2068 |
|
| 2069 |
/* If we want num work-groups X, see if we also want num work-groups Y. */ |
| 2070 |
if (has_num_work_groups_reg[0] && has_num_work_groups_reg[1]) { |
| 2071 |
/* Make sure we are going to DOUTW them into adjacent registers |
| 2072 |
* otherwise we can't do it in one. |
| 2073 |
*/ |
| 2074 |
assert(program->num_work_groups_regs[1] == |
| 2075 |
(program->num_work_groups_regs[0] + 1)); |
| 2076 |
|
| 2077 |
doutw = pvr_pds_encode_doutw_src1( |
| 2078 |
program->num_work_groups_regs[0], |
| 2079 |
PVR_PDS_DOUTW_LOWER64, |
| 2080 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_COMMON_STORE, |
| 2081 |
true, |
| 2082 |
dev_info); |
| 2083 |
|
| 2084 |
pvr_pds_write_constant32(buffer, num_work_groups_ctrl_words[0], doutw); |
| 2085 |
} |
| 2086 |
/* If we only want one of X or Y then handle them separately. */ |
| 2087 |
else { |
| 2088 |
if (has_num_work_groups_reg[0]) { |
| 2089 |
doutw = pvr_pds_encode_doutw_src1( |
| 2090 |
program->num_work_groups_regs[0], |
| 2091 |
PVR_PDS_DOUTW_LOWER32, |
| 2092 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_COMMON_STORE, |
| 2093 |
true, |
| 2094 |
dev_info); |
| 2095 |
|
| 2096 |
pvr_pds_write_constant32(buffer, |
| 2097 |
num_work_groups_ctrl_words[0], |
| 2098 |
doutw); |
| 2099 |
} else if (has_num_work_groups_reg[1]) { |
| 2100 |
doutw = pvr_pds_encode_doutw_src1( |
| 2101 |
program->num_work_groups_regs[1], |
| 2102 |
PVR_PDS_DOUTW_UPPER32, |
| 2103 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_COMMON_STORE, |
| 2104 |
true, |
| 2105 |
dev_info); |
| 2106 |
|
| 2107 |
pvr_pds_write_constant32(buffer, |
| 2108 |
num_work_groups_ctrl_words[0], |
| 2109 |
doutw); |
| 2110 |
} |
| 2111 |
} |
| 2112 |
|
| 2113 |
/* Handle num work-groups Z. */ |
| 2114 |
if (has_num_work_groups_reg[2]) { |
| 2115 |
doutw = pvr_pds_encode_doutw_src1( |
| 2116 |
program->num_work_groups_regs[2], |
| 2117 |
PVR_PDS_DOUTW_LOWER32, |
| 2118 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_COMMON_STORE, |
| 2119 |
true, |
| 2120 |
dev_info); |
| 2121 |
|
| 2122 |
pvr_pds_write_constant32(buffer, num_work_groups_ctrl_words[1], doutw); |
| 2123 |
} |
| 2124 |
|
| 2125 |
if (has_num_work_groups_regs) { |
| 2126 |
/* This is done in cmd_buffer instead. */ |
| 2127 |
/* doutd = 3 << PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTD_SRC1_BSIZE_SHIFT; |
| 2128 |
*/ |
| 2129 |
doutd = 0; |
| 2130 |
doutd |= program->num_work_groups_regs[0] |
| 2131 |
<< PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTD_SRC1_AO_SHIFT; |
| 2132 |
|
| 2133 |
doutd |= PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTD_SRC1_CMODE_CACHED | |
| 2134 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTD_SRC1_DEST_COMMON_STORE; |
| 2135 |
|
| 2136 |
doutd |= PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTD_SRC1_LAST_EN; |
| 2137 |
|
| 2138 |
pvr_pds_write_constant32(buffer, num_work_groups_ctrl_words[2], doutd); |
| 2139 |
} |
| 2140 |
|
| 2141 |
/* Handle the local IDs. */ |
| 2142 |
if (has_local_input_reg[1] || has_local_input_reg[2]) { |
| 2143 |
uint32_t dest_reg; |
| 2144 |
|
| 2145 |
/* If we want local id Y and Z make sure the compiler wants them in |
| 2146 |
* the same register. |
| 2147 |
*/ |
| 2148 |
if (!program->flattened_work_groups) { |
| 2149 |
if (has_local_input_reg[1] && has_local_input_reg[2]) { |
| 2150 |
assert(program->local_input_regs[1] == |
| 2151 |
program->local_input_regs[2]); |
| 2152 |
} |
| 2153 |
} |
| 2154 |
|
| 2155 |
if (has_local_input_reg[1]) |
| 2156 |
dest_reg = program->local_input_regs[1]; |
| 2157 |
else |
| 2158 |
dest_reg = program->local_input_regs[2]; |
| 2159 |
|
| 2160 |
/* If we want local id X and (Y or Z) then we can do that in a |
| 2161 |
* single 64-bit DOUTW. |
| 2162 |
*/ |
| 2163 |
if (has_local_input_reg[0]) { |
| 2164 |
assert(dest_reg == (program->local_input_regs[0] + 1)); |
| 2165 |
|
| 2166 |
doutw = pvr_pds_encode_doutw_src1( |
| 2167 |
program->local_input_regs[0], |
| 2168 |
PVR_PDS_DOUTW_LOWER64, |
| 2169 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_UNIFIED_STORE, |
| 2170 |
true, |
| 2171 |
dev_info); |
| 2172 |
|
| 2173 |
doutw |= PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_LAST_EN; |
| 2174 |
|
| 2175 |
pvr_pds_write_constant32(buffer, local_id_ctrl_word, doutw); |
| 2176 |
} |
| 2177 |
/* Otherwise just DMA in Y and Z together in a single 32-bit DOUTW. |
| 2178 |
*/ |
| 2179 |
else { |
| 2180 |
doutw = pvr_pds_encode_doutw_src1( |
| 2181 |
dest_reg, |
| 2182 |
PVR_PDS_DOUTW_UPPER32, |
| 2183 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_UNIFIED_STORE, |
| 2184 |
true, |
| 2185 |
dev_info); |
| 2186 |
|
| 2187 |
doutw |= PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_LAST_EN; |
| 2188 |
|
| 2189 |
pvr_pds_write_constant32(buffer, local_id_ctrl_word, doutw); |
| 2190 |
} |
| 2191 |
} |
| 2192 |
/* If we don't want Y or Z then just DMA in X in a single 32-bit DOUTW. |
| 2193 |
*/ |
| 2194 |
else if (has_local_input_reg[0]) { |
| 2195 |
doutw = pvr_pds_encode_doutw_src1( |
| 2196 |
program->local_input_regs[0], |
| 2197 |
PVR_PDS_DOUTW_LOWER32, |
| 2198 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_UNIFIED_STORE | |
| 2199 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_LAST_EN, |
| 2200 |
true, |
| 2201 |
dev_info); |
| 2202 |
|
| 2203 |
pvr_pds_write_constant32(buffer, local_id_ctrl_word, doutw); |
| 2204 |
} |
| 2205 |
} |
| 2206 |
|
| 2207 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT || |
| 2208 |
gen_mode == PDS_GENERATE_SIZES) { |
| 2209 |
const bool encode = (gen_mode == PDS_GENERATE_CODE_SEGMENT); |
| 2210 |
#define APPEND(X) \ |
| 2211 |
if (encode) { \ |
| 2212 |
*buffer = X; \ |
| 2213 |
buffer++; \ |
| 2214 |
} else { \ |
| 2215 |
code_size += sizeof(uint32_t); \ |
| 2216 |
} |
| 2217 |
|
| 2218 |
/* Assert that coeff_update_task_branch_size is > 0 because if it is 0 |
| 2219 |
* then we will be doing an infinite loop. |
| 2220 |
*/ |
| 2221 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) |
| 2222 |
assert(program->coeff_update_task_branch_size > 0); |
| 2223 |
|
| 2224 |
/* Test whether this is the coefficient update task or not. */ |
| 2225 |
APPEND( |
| 2226 |
pvr_pds_encode_bra(PVR_ROGUE_PDSINST_PREDICATE_IF1, /* SRCC */ |
| 2227 |
PVR_ROGUE_PDSINST_NEG_ENABLE, /* NEG */ |
| 2228 |
PVR_ROGUE_PDSINST_PREDICATE_KEEP, /* SETC */ |
| 2229 |
program->coeff_update_task_branch_size /* ADDR */)); |
| 2230 |
|
| 2231 |
/* Do we need to initialize the barrier coefficient? */ |
| 2232 |
if (has_barrier_coefficient) { |
| 2233 |
if (PVR_HAS_QUIRK(dev_info, 51210)) { |
| 2234 |
/* Initialize the second barrier coefficient registers to zero. |
| 2235 |
*/ |
| 2236 |
APPEND(pvr_pds_encode_doutw64(0, /* cc */ |
| 2237 |
0, /* END */ |
| 2238 |
barrier_ctrl_word2, /* SRC1 */ |
| 2239 |
zero_constant64 >> 1)); /* SRC0 */ |
| 2240 |
} |
| 2241 |
/* Initialize the coefficient register to zero. */ |
| 2242 |
APPEND(pvr_pds_encode_doutw64(0, /* cc */ |
| 2243 |
0, /* END */ |
| 2244 |
barrier_ctrl_word, /* SRC1 */ |
| 2245 |
zero_constant64 >> 1)); /* SRC0 */ |
| 2246 |
} |
| 2247 |
|
| 2248 |
/* Add base workgroup to workgroup ids. */ |
| 2249 |
for (uint32_t wg_comp = 0; wg_comp < 3; ++wg_comp) { |
| 2250 |
if (!has_work_group_input_reg[wg_comp]) |
| 2251 |
continue; |
| 2252 |
|
| 2253 |
APPEND(pvr_pds_inst_encode_add32( |
| 2254 |
/* cc */ 0x0, |
| 2255 |
/* ALUM */ 0, |
| 2256 |
/* SNA */ 0, |
| 2257 |
/* SRC0 (R32)*/ PVR_ROGUE_PDSINST_REGS32_CONST32_LOWER + |
| 2258 |
program->base_workgroup_constant_offset_in_dwords[wg_comp], |
| 2259 |
/* SRC1 (R32)*/ PVR_ROGUE_PDSINST_REGS32_TEMP32_LOWER + |
| 2260 |
wg_id_temps[wg_comp], |
| 2261 |
/* DST (R32TP)*/ PVR_ROGUE_PDSINST_REGS32TP_TEMP32_LOWER + |
| 2262 |
wg_id_temps[wg_comp])); |
| 2263 |
} |
| 2264 |
|
| 2265 |
/* If we are going to put the work-group IDs in coefficients then we |
| 2266 |
* just need to do the DOUTWs. |
| 2267 |
*/ |
| 2268 |
if (has_work_group_input_reg[0] || has_work_group_input_reg[1]) { |
| 2269 |
uint32_t src_reg; |
| 2270 |
|
| 2271 |
if (has_work_group_input_reg[0]) |
| 2272 |
src_reg = PVR_PDS_TEMPS_BLOCK_BASE + PVR_PDS_CDM_WORK_GROUP_ID_X; |
| 2273 |
else |
| 2274 |
src_reg = PVR_PDS_TEMPS_BLOCK_BASE + PVR_PDS_CDM_WORK_GROUP_ID_Y; |
| 2275 |
|
| 2276 |
APPEND(pvr_pds_encode_doutw64(0, /* cc */ |
| 2277 |
0, /* END */ |
| 2278 |
work_group_id_ctrl_words[0], /* SRC1 |
| 2279 |
*/ |
| 2280 |
src_reg >> 1)); /* SRC0 */ |
| 2281 |
} |
| 2282 |
|
| 2283 |
if (has_work_group_input_reg[2]) { |
| 2284 |
APPEND(pvr_pds_encode_doutw64( |
| 2285 |
0, /* cc */ |
| 2286 |
0, /* END */ |
| 2287 |
work_group_id_ctrl_words[1], /* SRC1 */ |
| 2288 |
(PVR_PDS_TEMPS_BLOCK_BASE + PVR_PDS_CDM_WORK_GROUP_ID_Z) >> |
| 2289 |
1)); /* SRC0 */ |
| 2290 |
} |
| 2291 |
|
| 2292 |
/* If we are going to put the num work-groups in coefficients then we |
| 2293 |
* just need to do the DOUTWs. |
| 2294 |
*/ |
| 2295 |
if (has_num_work_groups_reg[0] || has_num_work_groups_reg[1]) { |
| 2296 |
uint32_t src_reg; |
| 2297 |
|
| 2298 |
if (has_num_work_groups_reg[0]) |
| 2299 |
src_reg = PVR_PDS_CONSTANTS_BLOCK_BASE + |
| 2300 |
program->num_workgroups_constant_offset_in_dwords[0]; |
| 2301 |
else |
| 2302 |
src_reg = PVR_PDS_CONSTANTS_BLOCK_BASE + |
| 2303 |
program->num_workgroups_constant_offset_in_dwords[1]; |
| 2304 |
|
| 2305 |
APPEND(pvr_pds_encode_doutw64(0, /* cc */ |
| 2306 |
0, /* END */ |
| 2307 |
num_work_groups_ctrl_words[0], /* SRC1 */ |
| 2308 |
src_reg >> 1)); /* SRC0 */ |
| 2309 |
} |
| 2310 |
|
| 2311 |
if (has_num_work_groups_reg[2]) { |
| 2312 |
APPEND(pvr_pds_encode_doutw64( |
| 2313 |
0, /* cc */ |
| 2314 |
0, /* END */ |
| 2315 |
num_work_groups_ctrl_words[1], /* SRC1 */ |
| 2316 |
(PVR_PDS_CONSTANTS_BLOCK_BASE + |
| 2317 |
program->num_workgroups_constant_offset_in_dwords[2]) >> |
| 2318 |
1)); /* SRC0 */ |
| 2319 |
} |
| 2320 |
|
| 2321 |
/* TODO: this is hardcoded to assume that all three num workgroup |
| 2322 |
* elements are used... |
| 2323 |
*/ |
| 2324 |
if (has_num_work_groups_regs) { |
| 2325 |
APPEND(pvr_pds_encode_doutd( |
| 2326 |
/* cc */ 0, |
| 2327 |
/* END */ 0, |
| 2328 |
/* SRC1 */ num_work_groups_ctrl_words[2], /* DOUTD 32-bit Src1 */ |
| 2329 |
/* SRC0 */ program->num_workgroups_indirect_src >> 1)); /* DOUTD |
| 2330 |
* 64-bit |
| 2331 |
* Src0. |
| 2332 |
*/ |
| 2333 |
} |
| 2334 |
|
| 2335 |
/* Issue the task to the USC. */ |
| 2336 |
if (program->kick_usc && program->has_coefficient_update_task) { |
| 2337 |
APPEND(pvr_pds_encode_doutu(0, /* cc */ |
| 2338 |
1, /* END */ |
| 2339 |
usc_control_constant64_coeff_update >> |
| 2340 |
1)); /* SRC0; DOUTU 64-bit Src0 */ |
| 2341 |
} |
| 2342 |
|
| 2343 |
/* Encode a HALT */ |
| 2344 |
APPEND(pvr_pds_inst_encode_halt(0)); |
| 2345 |
|
| 2346 |
/* Set the branch size used to skip the coefficient sync task. */ |
| 2347 |
program->coeff_update_task_branch_size = code_size / sizeof(uint32_t); |
| 2348 |
|
| 2349 |
/* DOUTW in the local IDs. */ |
| 2350 |
|
| 2351 |
/* If we want X and Y or Z, we only need one DOUTW. */ |
| 2352 |
if (has_local_input_reg[0] && |
| 2353 |
(has_local_input_reg[1] || has_local_input_reg[2])) { |
| 2354 |
local_input_register = |
| 2355 |
PVR_PDS_TEMPS_BLOCK_BASE + PVR_PDS_CDM_LOCAL_ID_X; |
| 2356 |
} else { |
| 2357 |
/* If we just want X. */ |
| 2358 |
if (has_local_input_reg[0]) { |
| 2359 |
local_input_register = |
| 2360 |
PVR_PDS_TEMPS_BLOCK_BASE + PVR_PDS_CDM_LOCAL_ID_X; |
| 2361 |
} |
| 2362 |
/* If we just want Y or Z. */ |
| 2363 |
else if (has_local_input_reg[1] || has_local_input_reg[2]) { |
| 2364 |
local_input_register = |
| 2365 |
PVR_PDS_TEMPS_BLOCK_BASE + PVR_PDS_CDM_LOCAL_ID_YZ; |
| 2366 |
} |
| 2367 |
} |
| 2368 |
|
| 2369 |
if (has_local_input_regs) { |
| 2370 |
APPEND(pvr_pds_encode_doutw64(0, /* cc */ |
| 2371 |
0, /* END */ |
| 2372 |
local_id_ctrl_word, /* SRC1 */ |
| 2373 |
local_input_register >> 1)); /* SRC0 |
| 2374 |
*/ |
| 2375 |
} |
| 2376 |
|
| 2377 |
if (program->clear_pds_barrier) { |
| 2378 |
/* Zero the persistent temp (SW fence for context switch). */ |
| 2379 |
APPEND(pvr_pds_inst_encode_add64( |
| 2380 |
0, /* cc */ |
| 2381 |
PVR_ROGUE_PDSINST_ALUM_UNSIGNED, |
| 2382 |
PVR_ROGUE_PDSINST_MAD_SNA_ADD, |
| 2383 |
PVR_ROGUE_PDSINST_REGS64_CONST64_LOWER + |
| 2384 |
(zero_constant64 >> 1), /* src0 = 0 */ |
| 2385 |
PVR_ROGUE_PDSINST_REGS64_CONST64_LOWER + |
| 2386 |
(zero_constant64 >> 1), /* src1 = 0 */ |
| 2387 |
PVR_ROGUE_PDSINST_REGS64TP_PTEMP64_LOWER + 0)); /* dest = |
| 2388 |
* ptemp64[0] |
| 2389 |
*/ |
| 2390 |
} |
| 2391 |
|
| 2392 |
/* If this is a fence, issue the DOUTC. */ |
| 2393 |
if (program->fence) { |
| 2394 |
APPEND(pvr_pds_inst_encode_doutc(0, /* cc */ |
| 2395 |
0 /* END */)); |
| 2396 |
} |
| 2397 |
|
| 2398 |
if (program->kick_usc) { |
| 2399 |
if (program->conditional_render) { |
| 2400 |
/* Skip if coefficient update task. */ |
| 2401 |
APPEND(pvr_pds_inst_encode_bra(PVR_ROGUE_PDSINST_PREDICATE_IF1, |
| 2402 |
0, |
| 2403 |
PVR_ROGUE_PDSINST_PREDICATE_KEEP, |
| 2404 |
16)); |
| 2405 |
|
| 2406 |
/* Load the predicate. */ |
| 2407 |
APPEND(pvr_pds_inst_encode_ld(0, predicate_ld_src0_constant >> 1)); |
| 2408 |
|
| 2409 |
/* Load negate constant into temp for CMP. */ |
| 2410 |
APPEND(pvr_pds_inst_encode_add64( |
| 2411 |
0, /* cc */ |
| 2412 |
PVR_ROGUE_PDSINST_ALUM_UNSIGNED, |
| 2413 |
PVR_ROGUE_PDSINST_MAD_SNA_ADD, |
| 2414 |
PVR_ROGUE_PDSINST_REGS64_CONST64_LOWER + |
| 2415 |
(cond_render_negate_constant >> 1), /* src0 = 0 */ |
| 2416 |
PVR_ROGUE_PDSINST_REGS64_CONST64_LOWER + |
| 2417 |
(zero_constant64 >> 1), /* src1 = 0 */ |
| 2418 |
PVR_ROGUE_PDSINST_REGS64TP_TEMP64_LOWER + |
| 2419 |
(cond_render_negate_temp >> 1))); /* dest = ptemp64[0] |
| 2420 |
*/ |
| 2421 |
|
| 2422 |
APPEND(pvr_pds_inst_encode_wdf(0)); |
| 2423 |
|
| 2424 |
for (uint32_t i = 0; i < 4; i++) { |
| 2425 |
APPEND(pvr_pds_inst_encode_sftlp32( |
| 2426 |
1, /* enable immediate */ |
| 2427 |
0, /* cc */ |
| 2428 |
PVR_ROGUE_PDSINST_LOP_AND, /* LOP */ |
| 2429 |
cond_render_pred_temp + i, /* SRC0 */ |
| 2430 |
cond_render_pred_mask_constant + i, /* SRC1 */ |
| 2431 |
0, /* SRC2 (Shift) */ |
| 2432 |
cond_render_pred_temp + i)); /* DST */ |
| 2433 |
|
| 2434 |
APPEND( |
| 2435 |
pvr_pds_inst_encode_sftlp32(1, /* enable immediate */ |
| 2436 |
0, /* cc */ |
| 2437 |
PVR_ROGUE_PDSINST_LOP_OR, /* LOP |
| 2438 |
*/ |
| 2439 |
cond_render_pred_temp + i, /* SRC0 |
| 2440 |
*/ |
| 2441 |
cond_render_pred_temp, /* SRC1 */ |
| 2442 |
0, /* SRC2 (Shift) */ |
| 2443 |
cond_render_pred_temp)); /* DST */ |
| 2444 |
} |
| 2445 |
|
| 2446 |
APPEND(pvr_pds_inst_encode_limm(0, /* cc */ |
| 2447 |
cond_render_pred_temp + 1, /* SRC1 |
| 2448 |
*/ |
| 2449 |
0, /* SRC0 */ |
| 2450 |
0)); /* GLOBALREG */ |
| 2451 |
|
| 2452 |
APPEND(pvr_pds_inst_encode_sftlp32(1, /* enable immediate */ |
| 2453 |
0, /* cc */ |
| 2454 |
PVR_ROGUE_PDSINST_LOP_XOR, /* LOP |
| 2455 |
*/ |
| 2456 |
cond_render_pred_temp, /* SRC0 */ |
| 2457 |
cond_render_negate_temp, /* SRC1 |
| 2458 |
*/ |
| 2459 |
0, /* SRC2 (Shift) */ |
| 2460 |
cond_render_pred_temp)); /* DST |
| 2461 |
*/ |
| 2462 |
|
| 2463 |
/* Check that the predicate is 0. */ |
| 2464 |
APPEND(pvr_pds_inst_encode_cmpi( |
| 2465 |
0, /* cc */ |
| 2466 |
PVR_ROGUE_PDSINST_COP_EQ, /* LOP */ |
| 2467 |
(cond_render_pred_temp >> 1) + |
| 2468 |
PVR_ROGUE_PDSINST_REGS64TP_TEMP64_LOWER, /* SRC0 */ |
| 2469 |
0)); /* SRC1 */ |
| 2470 |
|
| 2471 |
/* If predicate is 0, skip DOUTU. */ |
| 2472 |
APPEND(pvr_pds_inst_encode_bra( |
| 2473 |
PVR_ROGUE_PDSINST_PREDICATE_P0, /* SRCC: |
| 2474 |
P0 */ |
| 2475 |
0, /* NEG */ |
| 2476 |
PVR_ROGUE_PDSINST_PREDICATE_KEEP, /* SETC: |
| 2477 |
keep |
| 2478 |
*/ |
| 2479 |
2)); |
| 2480 |
} |
| 2481 |
|
| 2482 |
/* Issue the task to the USC. |
| 2483 |
* DoutU src1=USC Code Base address, src2=doutu word 2. |
| 2484 |
*/ |
| 2485 |
APPEND(pvr_pds_encode_doutu(1, /* cc */ |
| 2486 |
1, /* END */ |
| 2487 |
usc_control_constant64 >> 1)); /* SRC0; |
| 2488 |
* DOUTU |
| 2489 |
* 64-bit |
| 2490 |
* Src0. |
| 2491 |
*/ |
| 2492 |
} |
| 2493 |
|
| 2494 |
/* End the program if the Dout did not already end it. */ |
| 2495 |
APPEND(pvr_pds_inst_encode_halt(0)); |
| 2496 |
#undef APPEND |
| 2497 |
} |
| 2498 |
|
| 2499 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 2500 |
/* Set the data segment pointer and ensure we return 1 past the buffer |
| 2501 |
* ptr. |
| 2502 |
*/ |
| 2503 |
program->data_segment = buffer; |
| 2504 |
|
| 2505 |
buffer += next_constant; |
| 2506 |
} |
| 2507 |
|
| 2508 |
/* Require at least one DWORD of PDS data so the program runs. */ |
| 2509 |
data_size = MAX2(1, data_size); |
| 2510 |
|
| 2511 |
program->temps_used = temps_used; |
| 2512 |
program->highest_temp = temps_used; |
| 2513 |
program->data_size = data_size; |
| 2514 |
if (gen_mode == PDS_GENERATE_SIZES) |
| 2515 |
program->code_size = code_size; |
| 2516 |
|
| 2517 |
return buffer; |
| 2518 |
} |
| 2519 |
|
| 2520 |
/** |
| 2521 |
* Generates the PDS vertex shader data or code block. This program will do a |
| 2522 |
* DMA into USC Constants followed by a DOUTU. |
| 2523 |
* |
| 2524 |
* \param program Pointer to the PDS vertex shader program. |
| 2525 |
* \param buffer Pointer to the buffer for the program. |
| 2526 |
* \param gen_mode Generate code or data. |
| 2527 |
* \param dev_info PVR device information struct. |
| 2528 |
* \returns Pointer to just beyond the code/data. |
| 2529 |
*/ |
| 2530 |
uint32_t *pvr_pds_vertex_shader_sa( |
| 2531 |
struct pvr_pds_vertex_shader_sa_program *restrict program, |
| 2532 |
uint32_t *restrict buffer, |
| 2533 |
enum pvr_pds_generate_mode gen_mode, |
| 2534 |
const struct pvr_device_info *dev_info) |
| 2535 |
{ |
| 2536 |
uint32_t next_constant; |
| 2537 |
uint32_t data_size = 0; |
| 2538 |
uint32_t code_size = 0; |
| 2539 |
|
| 2540 |
uint32_t usc_control_constant64 = 0; |
| 2541 |
uint32_t dma_address_constant64 = 0; |
| 2542 |
uint32_t dma_control_constant32 = 0; |
| 2543 |
uint32_t doutw_value_constant64 = 0; |
| 2544 |
uint32_t doutw_control_constant32 = 0; |
| 2545 |
uint32_t fence_constant_word = 0; |
| 2546 |
uint32_t *buffer_base; |
| 2547 |
uint32_t kick_index; |
| 2548 |
|
| 2549 |
uint32_t total_num_doutw = |
| 2550 |
program->num_dword_doutw + program->num_q_word_doutw; |
| 2551 |
uint32_t total_size_dma = |
| 2552 |
program->num_dword_doutw + 2 * program->num_q_word_doutw; |
| 2553 |
|
| 2554 |
next_constant = PVR_PDS_CONSTANTS_BLOCK_BASE; |
| 2555 |
|
| 2556 |
/* Copy the DMA control words and USC task control words to constants. |
| 2557 |
* |
| 2558 |
* Arrange them so that the 64-bit words are together followed by the 32-bit |
| 2559 |
* words. |
| 2560 |
*/ |
| 2561 |
if (program->kick_usc) { |
| 2562 |
usc_control_constant64 = |
| 2563 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 2564 |
} |
| 2565 |
|
| 2566 |
if (program->clear_pds_barrier) { |
| 2567 |
fence_constant_word = |
| 2568 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 2569 |
} |
| 2570 |
dma_address_constant64 = pvr_pds_get_constants(&next_constant, |
| 2571 |
2 * program->num_dma_kicks, |
| 2572 |
&data_size); |
| 2573 |
|
| 2574 |
/* Assign all unaligned constants together to avoid alignment issues caused |
| 2575 |
* by pvr_pds_get_constants with even allocation sizes. |
| 2576 |
*/ |
| 2577 |
doutw_value_constant64 = pvr_pds_get_constants( |
| 2578 |
&next_constant, |
| 2579 |
total_size_dma + total_num_doutw + program->num_dma_kicks, |
| 2580 |
&data_size); |
| 2581 |
doutw_control_constant32 = doutw_value_constant64 + total_size_dma; |
| 2582 |
dma_control_constant32 = doutw_control_constant32 + total_num_doutw; |
| 2583 |
|
| 2584 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 2585 |
buffer_base = buffer; |
| 2586 |
|
| 2587 |
if (program->kick_usc) { |
| 2588 |
/* Src0 for DOUTU. */ |
| 2589 |
pvr_pds_write_wide_constant(buffer_base, |
| 2590 |
usc_control_constant64, |
| 2591 |
program->usc_task_control.src0); /* DOUTU |
| 2592 |
* 64-bit |
| 2593 |
* Src0. |
| 2594 |
*/ |
| 2595 |
buffer += 2; |
| 2596 |
} |
| 2597 |
|
| 2598 |
if (program->clear_pds_barrier) { |
| 2599 |
/* Encode the fence constant src0. Fence barrier is initialized to |
| 2600 |
* zero. |
| 2601 |
*/ |
| 2602 |
pvr_pds_write_wide_constant(buffer_base, fence_constant_word, 0); |
| 2603 |
buffer += 2; |
| 2604 |
} |
| 2605 |
|
| 2606 |
if (total_num_doutw > 0) { |
| 2607 |
for (uint32_t i = 0; i < program->num_q_word_doutw; i++) { |
| 2608 |
/* Write the constant for the coefficient register write. */ |
| 2609 |
pvr_pds_write_constant64(buffer_base, |
| 2610 |
doutw_value_constant64, |
| 2611 |
program->q_word_doutw_value[2 * i], |
| 2612 |
program->q_word_doutw_value[2 * i + 1]); |
| 2613 |
pvr_pds_write_constant32( |
| 2614 |
buffer_base, |
| 2615 |
doutw_control_constant32, |
| 2616 |
program->q_word_doutw_control[i] | |
| 2617 |
((!program->num_dma_kicks && i == total_num_doutw - 1) |
| 2618 |
? PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_LAST_EN |
| 2619 |
: 0)); |
| 2620 |
|
| 2621 |
doutw_value_constant64 += 2; |
| 2622 |
doutw_control_constant32 += 1; |
| 2623 |
} |
| 2624 |
|
| 2625 |
for (uint32_t i = 0; i < program->num_dword_doutw; i++) { |
| 2626 |
/* Write the constant for the coefficient register write. */ |
| 2627 |
pvr_pds_write_constant32(buffer_base, |
| 2628 |
doutw_value_constant64, |
| 2629 |
program->dword_doutw_value[i]); |
| 2630 |
pvr_pds_write_constant32( |
| 2631 |
buffer_base, |
| 2632 |
doutw_control_constant32, |
| 2633 |
program->dword_doutw_control[i] | |
| 2634 |
((!program->num_dma_kicks && i == program->num_dword_doutw - 1) |
| 2635 |
? PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_LAST_EN |
| 2636 |
: 0)); |
| 2637 |
|
| 2638 |
doutw_value_constant64 += 1; |
| 2639 |
doutw_control_constant32 += 1; |
| 2640 |
} |
| 2641 |
|
| 2642 |
buffer += total_size_dma + total_num_doutw; |
| 2643 |
} |
| 2644 |
|
| 2645 |
if (program->num_dma_kicks == 1) /* Most-common case. */ |
| 2646 |
{ |
| 2647 |
/* Src0 for DOUTD - Address. */ |
| 2648 |
pvr_pds_write_dma_address(buffer_base, |
| 2649 |
dma_address_constant64, |
| 2650 |
program->dma_address[0], |
| 2651 |
false, |
| 2652 |
dev_info); |
| 2653 |
|
| 2654 |
/* Src1 for DOUTD - Control Word. */ |
| 2655 |
pvr_pds_write_constant32( |
| 2656 |
buffer_base, |
| 2657 |
dma_control_constant32, |
| 2658 |
program->dma_control[0] | |
| 2659 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTD_SRC1_LAST_EN); |
| 2660 |
|
| 2661 |
/* Move the buffer ptr along as we will return 1 past the buffer. */ |
| 2662 |
buffer += 3; |
| 2663 |
} else if (program->num_dma_kicks > 1) { |
| 2664 |
for (kick_index = 0; kick_index < program->num_dma_kicks - 1; |
| 2665 |
kick_index++) { |
| 2666 |
/* Src0 for DOUTD - Address. */ |
| 2667 |
pvr_pds_write_dma_address(buffer_base, |
| 2668 |
dma_address_constant64, |
| 2669 |
program->dma_address[kick_index], |
| 2670 |
false, |
| 2671 |
dev_info); |
| 2672 |
|
| 2673 |
/* Src1 for DOUTD - Control Word. */ |
| 2674 |
pvr_pds_write_constant32(buffer_base, |
| 2675 |
dma_control_constant32, |
| 2676 |
program->dma_control[kick_index]); |
| 2677 |
dma_address_constant64 += 2; |
| 2678 |
dma_control_constant32 += 1; |
| 2679 |
} |
| 2680 |
|
| 2681 |
/* Src0 for DOUTD - Address. */ |
| 2682 |
pvr_pds_write_dma_address(buffer_base, |
| 2683 |
dma_address_constant64, |
| 2684 |
program->dma_address[kick_index], |
| 2685 |
false, |
| 2686 |
dev_info); |
| 2687 |
|
| 2688 |
/* Src1 for DOUTD - Control Word. */ |
| 2689 |
pvr_pds_write_constant32( |
| 2690 |
buffer_base, |
| 2691 |
dma_control_constant32, |
| 2692 |
program->dma_control[kick_index] | |
| 2693 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTD_SRC1_LAST_EN); |
| 2694 |
|
| 2695 |
buffer += 3 * program->num_dma_kicks; |
| 2696 |
} |
| 2697 |
} else if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 2698 |
if (program->clear_pds_barrier) { |
| 2699 |
/* Zero the persistent temp (SW fence for context switch). */ |
| 2700 |
*buffer++ = pvr_pds_inst_encode_add64( |
| 2701 |
0, /* cc */ |
| 2702 |
PVR_ROGUE_PDSINST_ALUM_UNSIGNED, |
| 2703 |
PVR_ROGUE_PDSINST_MAD_SNA_ADD, |
| 2704 |
PVR_ROGUE_PDSINST_REGS64_CONST64_LOWER + |
| 2705 |
(fence_constant_word >> 1), /* src0 = 0 */ |
| 2706 |
PVR_ROGUE_PDSINST_REGS64_CONST64_LOWER + |
| 2707 |
(fence_constant_word >> 1), /* src1 = 0 */ |
| 2708 |
PVR_ROGUE_PDSINST_REGS64TP_PTEMP64_LOWER + 0); /* dest = |
| 2709 |
* ptemp[0] |
| 2710 |
*/ |
| 2711 |
} |
| 2712 |
|
| 2713 |
if (total_num_doutw > 0) { |
| 2714 |
for (uint32_t i = 0; i < program->num_q_word_doutw; i++) { |
| 2715 |
/* Set the coefficient register to data value. */ |
| 2716 |
*buffer++ = pvr_pds_encode_doutw64( |
| 2717 |
/* cc */ 0, |
| 2718 |
/* END */ !program->num_dma_kicks && !program->kick_usc && |
| 2719 |
(i == total_num_doutw - 1), |
| 2720 |
/* SRC1 */ doutw_control_constant32, |
| 2721 |
/* SRC0 */ doutw_value_constant64 >> 1); |
| 2722 |
|
| 2723 |
doutw_value_constant64 += 2; |
| 2724 |
doutw_control_constant32 += 1; |
| 2725 |
} |
| 2726 |
|
| 2727 |
for (uint32_t i = 0; i < program->num_dword_doutw; i++) { |
| 2728 |
/* Set the coefficient register to data value. */ |
| 2729 |
*buffer++ = pvr_pds_encode_doutw64( |
| 2730 |
/* cc */ 0, |
| 2731 |
/* END */ !program->num_dma_kicks && !program->kick_usc && |
| 2732 |
(i == program->num_dword_doutw - 1), |
| 2733 |
/* SRC1 */ doutw_control_constant32, |
| 2734 |
/* SRC0 */ doutw_value_constant64 >> 1); |
| 2735 |
|
| 2736 |
doutw_value_constant64 += 1; |
| 2737 |
doutw_control_constant32 += 1; |
| 2738 |
} |
| 2739 |
} |
| 2740 |
|
| 2741 |
if (program->num_dma_kicks != 0) { |
| 2742 |
/* DMA the state into the secondary attributes. */ |
| 2743 |
|
| 2744 |
if (program->num_dma_kicks == 1) /* Most-common case. */ |
| 2745 |
{ |
| 2746 |
*buffer++ = pvr_pds_encode_doutd( |
| 2747 |
/* cc */ 0, |
| 2748 |
/* END */ !program->kick_usc, |
| 2749 |
/* SRC1 */ dma_control_constant32, /* DOUTD 32-bit Src1 */ |
| 2750 |
/* SRC0 */ dma_address_constant64 >> 1); /* DOUTD 64-bit |
| 2751 |
* Src0. |
| 2752 |
*/ |
| 2753 |
} else { |
| 2754 |
for (kick_index = 0; kick_index < program->num_dma_kicks; |
| 2755 |
kick_index++) { |
| 2756 |
*buffer++ = pvr_pds_encode_doutd( |
| 2757 |
/* cc */ 0, |
| 2758 |
/* END */ (!program->kick_usc) && |
| 2759 |
(kick_index + 1 == program->num_dma_kicks), |
| 2760 |
/* SRC1 */ dma_control_constant32, /* DOUTD 32-bit |
| 2761 |
* Src1. |
| 2762 |
*/ |
| 2763 |
/* SRC0 */ dma_address_constant64 >> 1); /* DOUTD |
| 2764 |
* 64-bit |
| 2765 |
* Src0. |
| 2766 |
*/ |
| 2767 |
dma_address_constant64 += 2; |
| 2768 |
dma_control_constant32 += 1; |
| 2769 |
} |
| 2770 |
} |
| 2771 |
} |
| 2772 |
|
| 2773 |
if (program->kick_usc) { |
| 2774 |
/* Kick the USC. */ |
| 2775 |
*buffer++ = pvr_pds_encode_doutu( |
| 2776 |
/* cc */ 0, |
| 2777 |
/* END */ 1, |
| 2778 |
/* SRC0 */ usc_control_constant64 >> 1); /* DOUTU 64-bit Src0. |
| 2779 |
*/ |
| 2780 |
} |
| 2781 |
|
| 2782 |
if (!program->kick_usc && program->num_dma_kicks == 0 && |
| 2783 |
total_num_doutw == 0) { |
| 2784 |
*buffer++ = pvr_pds_inst_encode_halt(0); |
| 2785 |
} |
| 2786 |
} |
| 2787 |
|
| 2788 |
code_size = program->num_dma_kicks + total_num_doutw; |
| 2789 |
if (program->clear_pds_barrier) |
| 2790 |
code_size++; /* ADD64 instruction. */ |
| 2791 |
|
| 2792 |
if (program->kick_usc) |
| 2793 |
code_size++; |
| 2794 |
|
| 2795 |
/* If there are no DMAs and no USC kick then code is HALT only. */ |
| 2796 |
if (code_size == 0) |
| 2797 |
code_size = 1; |
| 2798 |
|
| 2799 |
program->data_size = data_size; |
| 2800 |
program->code_size = code_size; |
| 2801 |
|
| 2802 |
return buffer; |
| 2803 |
} |
| 2804 |
|
| 2805 |
/** |
| 2806 |
* Writes the Uniform Data block for the PDS pixel shader secondary attributes |
| 2807 |
* program. |
| 2808 |
* |
| 2809 |
* \param program Pointer to the PDS pixel shader secondary attributes program. |
| 2810 |
* \param buffer Pointer to the buffer for the code/data. |
| 2811 |
* \param gen_mode Either code or data can be generated or sizes only updated. |
| 2812 |
* \returns Pointer to just beyond the buffer for the program/data. |
| 2813 |
*/ |
| 2814 |
uint32_t *pvr_pds_pixel_shader_uniform_texture_code( |
| 2815 |
struct pvr_pds_pixel_shader_sa_program *restrict program, |
| 2816 |
uint32_t *restrict buffer, |
| 2817 |
enum pvr_pds_generate_mode gen_mode) |
| 2818 |
{ |
| 2819 |
uint32_t *instruction; |
| 2820 |
uint32_t code_size = 0; |
| 2821 |
uint32_t data_size = 0; |
| 2822 |
uint32_t temps_used = 0; |
| 2823 |
uint32_t next_constant; |
| 2824 |
|
| 2825 |
assert((((uintptr_t)buffer) & (PDS_ROGUE_TA_STATE_PDS_ADDR_ALIGNSIZE - 1)) == |
| 2826 |
0); |
| 2827 |
|
| 2828 |
assert((gen_mode == PDS_GENERATE_CODE_SEGMENT && buffer) || |
| 2829 |
gen_mode == PDS_GENERATE_SIZES); |
| 2830 |
|
| 2831 |
/* clang-format off */ |
| 2832 |
/* Shape of code segment (note: clear is different) |
| 2833 |
* |
| 2834 |
* Code |
| 2835 |
* +------------+ |
| 2836 |
* | BRA if0 | |
| 2837 |
* | DOUTD | |
| 2838 |
* | ... | |
| 2839 |
* | DOUTD.halt | |
| 2840 |
* | uniform | |
| 2841 |
* | DOUTD | |
| 2842 |
* | ... | |
| 2843 |
* | ... | |
| 2844 |
* | DOUTW | |
| 2845 |
* | ... | |
| 2846 |
* | ... | |
| 2847 |
* | DOUTU.halt | |
| 2848 |
* | HALT | |
| 2849 |
* +------------+ |
| 2850 |
*/ |
| 2851 |
/* clang-format on */ |
| 2852 |
instruction = buffer; |
| 2853 |
|
| 2854 |
next_constant = PVR_PDS_CONSTANTS_BLOCK_BASE; |
| 2855 |
|
| 2856 |
/* The clear color can arrive packed in the right form in the first (or |
| 2857 |
* first 2) dwords of the shared registers and the program will issue a |
| 2858 |
* single doutw for this. |
| 2859 |
*/ |
| 2860 |
if (program->clear && program->packed_clear) { |
| 2861 |
uint32_t color_constant1 = |
| 2862 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 2863 |
|
| 2864 |
uint32_t control_word_constant1 = |
| 2865 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 2866 |
|
| 2867 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 2868 |
/* DOUTW the clear color to the USC constants. Predicate with |
| 2869 |
* uniform loading flag (IF0). |
| 2870 |
*/ |
| 2871 |
*instruction++ = pvr_pds_encode_doutw64( |
| 2872 |
/* cc */ 1, /* Only for uniform loading program. */ |
| 2873 |
/* END */ program->kick_usc ? 0 : 1, /* Last |
| 2874 |
* instruction |
| 2875 |
* for a clear. |
| 2876 |
*/ |
| 2877 |
/* SRC1 */ control_word_constant1, /* DOUTW 32-bit Src1 */ |
| 2878 |
/* SRC0 */ color_constant1 >> 1); /* DOUTW 64-bit Src0 */ |
| 2879 |
|
| 2880 |
code_size += 1; |
| 2881 |
} |
| 2882 |
} else if (program->clear) { |
| 2883 |
uint32_t color_constant1, color_constant2; |
| 2884 |
|
| 2885 |
if (program->clear_color_dest_reg & 0x1) { |
| 2886 |
uint32_t color_constant3, control_word_constant1, |
| 2887 |
control_word_constant2, color_constant4; |
| 2888 |
|
| 2889 |
color_constant1 = pvr_pds_get_constants(&next_constant, 1, &data_size); |
| 2890 |
color_constant2 = pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 2891 |
color_constant3 = pvr_pds_get_constants(&next_constant, 1, &data_size); |
| 2892 |
|
| 2893 |
control_word_constant1 = |
| 2894 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 2895 |
control_word_constant2 = |
| 2896 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 2897 |
color_constant4 = pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 2898 |
|
| 2899 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 2900 |
/* DOUTW the clear color to the USSE constants. Predicate with |
| 2901 |
* uniform loading flag (IF0). |
| 2902 |
*/ |
| 2903 |
*instruction++ = pvr_pds_encode_doutw64( |
| 2904 |
/* cc */ 1, /* Only for Uniform Loading program */ |
| 2905 |
/* END */ 0, |
| 2906 |
/* SRC1 */ control_word_constant1, /* DOUTW 32-bit Src1 */ |
| 2907 |
/* SRC0 */ color_constant1 >> 1); /* DOUTW 64-bit Src0 */ |
| 2908 |
|
| 2909 |
*instruction++ = pvr_pds_encode_doutw64( |
| 2910 |
/* cc */ 1, /* Only for Uniform Loading program */ |
| 2911 |
/* END */ 0, |
| 2912 |
/* SRC1 */ control_word_constant2, /* DOUTW 32-bit Src1 */ |
| 2913 |
/* SRC0 */ color_constant2 >> 1); /* DOUTW 64-bit Src0 */ |
| 2914 |
|
| 2915 |
*instruction++ = pvr_pds_encode_doutw64( |
| 2916 |
/* cc */ 1, /* Only for uniform loading program */ |
| 2917 |
/* END */ program->kick_usc ? 0 : 1, /* Last |
| 2918 |
* instruction |
| 2919 |
* for a clear. |
| 2920 |
*/ |
| 2921 |
/* SRC1 */ color_constant4, /* DOUTW 32-bit Src1 */ |
| 2922 |
/* SRC0 */ color_constant3 >> 1); /* DOUTW 64-bit Src0 */ |
| 2923 |
} |
| 2924 |
|
| 2925 |
code_size += 3; |
| 2926 |
} else { |
| 2927 |
uint32_t control_word_constant, control_word_last_constant; |
| 2928 |
|
| 2929 |
/* Put the clear color and control words into the first 8 |
| 2930 |
* constants. |
| 2931 |
*/ |
| 2932 |
color_constant1 = pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 2933 |
color_constant2 = pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 2934 |
control_word_constant = |
| 2935 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 2936 |
control_word_last_constant = |
| 2937 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 2938 |
|
| 2939 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 2940 |
/* DOUTW the clear color to the USSE constants. Predicate with |
| 2941 |
* uniform loading flag (IF0). |
| 2942 |
*/ |
| 2943 |
*instruction++ = pvr_pds_encode_doutw64( |
| 2944 |
/* cc */ 1, /* Only for Uniform Loading program */ |
| 2945 |
/* END */ 0, |
| 2946 |
/* SRC1 */ control_word_constant, /* DOUTW 32-bit Src1 */ |
| 2947 |
/* SRC0 */ color_constant1 >> 1); /* DOUTW 64-bit Src0 */ |
| 2948 |
|
| 2949 |
*instruction++ = pvr_pds_encode_doutw64( |
| 2950 |
/* cc */ 1, /* Only for uniform loading program */ |
| 2951 |
/* END */ program->kick_usc ? 0 : 1, /* Last |
| 2952 |
* instruction |
| 2953 |
* for a clear. |
| 2954 |
*/ |
| 2955 |
/* SRC1 */ control_word_last_constant, /* DOUTW 32-bit Src1 |
| 2956 |
*/ |
| 2957 |
/* SRC0 */ color_constant2 >> 1); /* DOUTW 64-bit Src0 */ |
| 2958 |
} |
| 2959 |
|
| 2960 |
code_size += 2; |
| 2961 |
} |
| 2962 |
|
| 2963 |
if (program->kick_usc) { |
| 2964 |
uint32_t doutu_constant64; |
| 2965 |
|
| 2966 |
doutu_constant64 = |
| 2967 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 2968 |
|
| 2969 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 2970 |
/* Issue the task to the USC. |
| 2971 |
* |
| 2972 |
* dout ds1[constant_use], ds0[constant_use], |
| 2973 |
* ds1[constant_use], emit |
| 2974 |
*/ |
| 2975 |
*instruction++ = pvr_pds_encode_doutu( |
| 2976 |
/* cc */ 0, |
| 2977 |
/* END */ 1, |
| 2978 |
/* SRC0 */ doutu_constant64 >> 1); /* DOUTU 64-bit Src0 |
| 2979 |
*/ |
| 2980 |
} |
| 2981 |
|
| 2982 |
code_size += 1; |
| 2983 |
} |
| 2984 |
|
| 2985 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 2986 |
/* End the program. */ |
| 2987 |
*instruction++ = pvr_pds_inst_encode_halt(0); |
| 2988 |
} |
| 2989 |
code_size += 1; |
| 2990 |
} else { |
| 2991 |
uint32_t total_num_doutw = |
| 2992 |
program->num_dword_doutw + program->num_q_word_doutw; |
| 2993 |
bool both_textures_and_uniforms = |
| 2994 |
((program->num_texture_dma_kicks > 0) && |
| 2995 |
((program->num_uniform_dma_kicks > 0 || total_num_doutw > 0) || |
| 2996 |
program->kick_usc)); |
| 2997 |
uint32_t doutu_constant64 = 0; |
| 2998 |
|
| 2999 |
if (both_textures_and_uniforms) { |
| 3000 |
/* If the size of a PDS data section is 0, the hardware won't run |
| 3001 |
* it. We therefore don't need to branch when there is only a |
| 3002 |
* texture OR a uniform update program. |
| 3003 |
*/ |
| 3004 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 3005 |
uint32_t branch_address = |
| 3006 |
MAX2(1 + program->num_texture_dma_kicks, 2); |
| 3007 |
|
| 3008 |
/* Use If0 to BRAnch to uniform code. */ |
| 3009 |
*instruction++ = pvr_pds_encode_bra( |
| 3010 |
/* SRCC */ PVR_ROGUE_PDSINST_PREDICATE_IF0, |
| 3011 |
/* NEG */ PVR_ROGUE_PDSINST_NEG_DISABLE, |
| 3012 |
/* SETC */ PVR_ROGUE_PDSINST_PREDICATE_KEEP, |
| 3013 |
/* ADDR */ branch_address); |
| 3014 |
} |
| 3015 |
|
| 3016 |
code_size += 1; |
| 3017 |
} |
| 3018 |
|
| 3019 |
if (program->num_texture_dma_kicks > 0) { |
| 3020 |
uint32_t dma_address_constant64; |
| 3021 |
uint32_t dma_control_constant32; |
| 3022 |
/* Allocate 3 constant spaces for each kick. The 64-bit constants |
| 3023 |
* come first followed by the 32-bit constants. |
| 3024 |
*/ |
| 3025 |
dma_address_constant64 = PVR_PDS_CONSTANTS_BLOCK_BASE; |
| 3026 |
dma_control_constant32 = |
| 3027 |
dma_address_constant64 + (program->num_texture_dma_kicks * 2); |
| 3028 |
|
| 3029 |
for (uint32_t dma = 0; dma < program->num_texture_dma_kicks; dma++) { |
| 3030 |
code_size += 1; |
| 3031 |
if (gen_mode != PDS_GENERATE_CODE_SEGMENT) |
| 3032 |
continue; |
| 3033 |
|
| 3034 |
/* DMA the state into the secondary attributes. */ |
| 3035 |
*instruction++ = pvr_pds_encode_doutd( |
| 3036 |
/* cc */ 0, |
| 3037 |
/* END */ dma == (program->num_texture_dma_kicks - 1), |
| 3038 |
/* SRC1 */ dma_control_constant32, /* DOUT 32-bit Src1 */ |
| 3039 |
/* SRC0 */ dma_address_constant64 >> 1); /* DOUT |
| 3040 |
* 64-bit |
| 3041 |
* Src0 |
| 3042 |
*/ |
| 3043 |
dma_address_constant64 += 2; |
| 3044 |
dma_control_constant32 += 1; |
| 3045 |
} |
| 3046 |
} else if (both_textures_and_uniforms) { |
| 3047 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 3048 |
/* End the program. */ |
| 3049 |
*instruction++ = pvr_pds_inst_encode_halt(0); |
| 3050 |
} |
| 3051 |
|
| 3052 |
code_size += 1; |
| 3053 |
} |
| 3054 |
|
| 3055 |
/* Reserve space at the beginning of the data segment for the DOUTU Task |
| 3056 |
* Control if one is needed. |
| 3057 |
*/ |
| 3058 |
if (program->kick_usc) { |
| 3059 |
doutu_constant64 = |
| 3060 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 3061 |
} |
| 3062 |
|
| 3063 |
/* Allocate 3 constant spaces for each DMA and 2 for a USC kick. The |
| 3064 |
* 64-bit constants come first followed by the 32-bit constants. |
| 3065 |
*/ |
| 3066 |
uint32_t total_size_dma = |
| 3067 |
program->num_dword_doutw + 2 * program->num_q_word_doutw; |
| 3068 |
|
| 3069 |
uint32_t dma_address_constant64 = pvr_pds_get_constants( |
| 3070 |
&next_constant, |
| 3071 |
program->num_uniform_dma_kicks * 3 + total_size_dma + total_num_doutw, |
| 3072 |
&data_size); |
| 3073 |
uint32_t doutw_value_constant64 = |
| 3074 |
dma_address_constant64 + program->num_uniform_dma_kicks * 2; |
| 3075 |
uint32_t dma_control_constant32 = doutw_value_constant64 + total_size_dma; |
| 3076 |
uint32_t doutw_control_constant32 = |
| 3077 |
dma_control_constant32 + program->num_uniform_dma_kicks; |
| 3078 |
|
| 3079 |
if (total_num_doutw > 0) { |
| 3080 |
pvr_pds_get_constants(&next_constant, 0, &data_size); |
| 3081 |
|
| 3082 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 3083 |
for (uint32_t i = 0; i < program->num_q_word_doutw; i++) { |
| 3084 |
/* Set the coefficient register to data value. */ |
| 3085 |
*instruction++ = pvr_pds_encode_doutw64( |
| 3086 |
/* cc */ 0, |
| 3087 |
/* END */ !program->num_uniform_dma_kicks && |
| 3088 |
!program->kick_usc && (i == total_num_doutw - 1), |
| 3089 |
/* SRC1 */ doutw_control_constant32, |
| 3090 |
/* SRC0 */ doutw_value_constant64 >> 1); |
| 3091 |
|
| 3092 |
doutw_value_constant64 += 2; |
| 3093 |
doutw_control_constant32 += 1; |
| 3094 |
} |
| 3095 |
|
| 3096 |
for (uint32_t i = 0; i < program->num_dword_doutw; i++) { |
| 3097 |
/* Set the coefficient register to data value. */ |
| 3098 |
*instruction++ = pvr_pds_encode_doutw64( |
| 3099 |
/* cc */ 0, |
| 3100 |
/* END */ !program->num_uniform_dma_kicks && |
| 3101 |
!program->kick_usc && (i == program->num_dword_doutw - 1), |
| 3102 |
/* SRC1 */ doutw_control_constant32, |
| 3103 |
/* SRC0 */ doutw_value_constant64 >> 1); |
| 3104 |
|
| 3105 |
doutw_value_constant64 += 1; |
| 3106 |
doutw_control_constant32 += 1; |
| 3107 |
} |
| 3108 |
} |
| 3109 |
code_size += total_num_doutw; |
| 3110 |
} |
| 3111 |
|
| 3112 |
if (program->num_uniform_dma_kicks > 0) { |
| 3113 |
for (uint32_t dma = 0; dma < program->num_uniform_dma_kicks; dma++) { |
| 3114 |
code_size += 1; |
| 3115 |
|
| 3116 |
if (gen_mode != PDS_GENERATE_CODE_SEGMENT) |
| 3117 |
continue; |
| 3118 |
|
| 3119 |
bool last_instruction = false; |
| 3120 |
if (!program->kick_usc && |
| 3121 |
(dma == program->num_uniform_dma_kicks - 1)) { |
| 3122 |
last_instruction = true; |
| 3123 |
} |
| 3124 |
/* DMA the state into the secondary attributes. */ |
| 3125 |
*instruction++ = pvr_pds_encode_doutd( |
| 3126 |
/* cc */ 0, |
| 3127 |
/* END */ last_instruction, |
| 3128 |
/* SRC1 */ dma_control_constant32, /* DOUT 32-bit Src1 |
| 3129 |
*/ |
| 3130 |
/* SRC0 */ dma_address_constant64 >> 1); /* DOUT |
| 3131 |
* 64-bit |
| 3132 |
* Src0 |
| 3133 |
*/ |
| 3134 |
dma_address_constant64 += 2; |
| 3135 |
dma_control_constant32 += 1; |
| 3136 |
} |
| 3137 |
} |
| 3138 |
|
| 3139 |
if (program->kick_usc) { |
| 3140 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 3141 |
/* Issue the task to the USC. |
| 3142 |
* |
| 3143 |
* dout ds1[constant_use], ds0[constant_use], |
| 3144 |
* ds1[constant_use], emit |
| 3145 |
*/ |
| 3146 |
|
| 3147 |
*instruction++ = pvr_pds_encode_doutu( |
| 3148 |
/* cc */ 0, |
| 3149 |
/* END */ 1, |
| 3150 |
/* SRC0 */ doutu_constant64 >> 1); /* DOUTU 64-bit Src0 */ |
| 3151 |
} |
| 3152 |
|
| 3153 |
code_size += 1; |
| 3154 |
} else if (program->num_uniform_dma_kicks == 0 && total_num_doutw == 0) { |
| 3155 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 3156 |
/* End the program. */ |
| 3157 |
*instruction++ = pvr_pds_inst_encode_halt(0); |
| 3158 |
} |
| 3159 |
|
| 3160 |
code_size += 1; |
| 3161 |
} |
| 3162 |
} |
| 3163 |
|
| 3164 |
/* Minimum temp count is 1. */ |
| 3165 |
program->temps_used = MAX2(temps_used, 1); |
| 3166 |
program->code_size = code_size; |
| 3167 |
|
| 3168 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) |
| 3169 |
return instruction; |
| 3170 |
else |
| 3171 |
return NULL; |
| 3172 |
} |
| 3173 |
|
| 3174 |
/** |
| 3175 |
* Writes the Uniform Data block for the PDS pixel shader secondary attributes |
| 3176 |
* program. |
| 3177 |
* |
| 3178 |
* \param program Pointer to the PDS pixel shader secondary attributes program. |
| 3179 |
* \param buffer Pointer to the buffer for the code/data. |
| 3180 |
* \param gen_mode Either code or data can be generated or sizes only updated. |
| 3181 |
* \param dev_info PVR device information struct. |
| 3182 |
* \returns Pointer to just beyond the buffer for the program/data. |
| 3183 |
*/ |
| 3184 |
uint32_t *pvr_pds_pixel_shader_uniform_texture_data( |
| 3185 |
struct pvr_pds_pixel_shader_sa_program *restrict program, |
| 3186 |
uint32_t *restrict buffer, |
| 3187 |
enum pvr_pds_generate_mode gen_mode, |
| 3188 |
bool uniform, |
| 3189 |
const struct pvr_device_info *dev_info) |
| 3190 |
{ |
| 3191 |
uint32_t *constants = buffer; |
| 3192 |
uint32_t next_constant = PVR_PDS_CONSTANTS_BLOCK_BASE; |
| 3193 |
uint32_t temps_used = 0; |
| 3194 |
uint32_t data_size = 0; |
| 3195 |
|
| 3196 |
assert((((uintptr_t)buffer) & (PDS_ROGUE_TA_STATE_PDS_ADDR_ALIGNSIZE - 1)) == |
| 3197 |
0); |
| 3198 |
|
| 3199 |
assert(gen_mode != PDS_GENERATE_CODE_SEGMENT); |
| 3200 |
|
| 3201 |
/* Shape of data segment (note: clear is different). |
| 3202 |
* |
| 3203 |
* Uniform Texture |
| 3204 |
* +--------------+ +-------------+ |
| 3205 |
* | USC Task L | | USC Task L | |
| 3206 |
* | H | | H | |
| 3207 |
* | DMA1 Src0 L | | DMA1 Src0 L | |
| 3208 |
* | H | | H | |
| 3209 |
* | DMA2 Src0 L | | | |
| 3210 |
* | H | | | |
| 3211 |
* | DMA1 Src1 | | DMA1 Src1 | |
| 3212 |
* | DMA2 Src1 | | | |
| 3213 |
* | DOUTW0 Src1 | | | |
| 3214 |
* | DOUTW1 Src1 | | | |
| 3215 |
* | ... | | | |
| 3216 |
* | DOUTWn Srcn | | | |
| 3217 |
* | other data | | | |
| 3218 |
* +--------------+ +-------------+ |
| 3219 |
*/ |
| 3220 |
|
| 3221 |
/* Generate the PDS pixel shader secondary attributes data. |
| 3222 |
* |
| 3223 |
* Packed Clear |
| 3224 |
* The clear color can arrive packed in the right form in the first (or |
| 3225 |
* first 2) dwords of the shared registers and the program will issue a |
| 3226 |
* single DOUTW for this. |
| 3227 |
*/ |
| 3228 |
if (program->clear && uniform && program->packed_clear) { |
| 3229 |
uint32_t color_constant1 = |
| 3230 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 3231 |
|
| 3232 |
uint32_t control_word_constant1 = |
| 3233 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 3234 |
|
| 3235 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 3236 |
uint32_t doutw; |
| 3237 |
|
| 3238 |
pvr_pds_write_constant64(constants, |
| 3239 |
color_constant1, |
| 3240 |
program->clear_color[0], |
| 3241 |
program->clear_color[1]); |
| 3242 |
|
| 3243 |
/* Load into first constant in common store. */ |
| 3244 |
doutw = pvr_pds_encode_doutw_src1( |
| 3245 |
program->clear_color_dest_reg, |
| 3246 |
PVR_PDS_DOUTW_LOWER64, |
| 3247 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_COMMON_STORE, |
| 3248 |
false, |
| 3249 |
dev_info); |
| 3250 |
|
| 3251 |
/* Set the last flag. */ |
| 3252 |
doutw |= PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_LAST_EN; |
| 3253 |
pvr_pds_write_constant64(constants, control_word_constant1, doutw, 0); |
| 3254 |
} |
| 3255 |
} else if (program->clear && uniform) { |
| 3256 |
uint32_t color_constant1, color_constant2; |
| 3257 |
|
| 3258 |
if (program->clear_color_dest_reg & 0x1) { |
| 3259 |
uint32_t color_constant3, control_word_constant1, |
| 3260 |
control_word_constant2, color_constant4; |
| 3261 |
|
| 3262 |
color_constant1 = pvr_pds_get_constants(&next_constant, 1, &data_size); |
| 3263 |
color_constant2 = pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 3264 |
color_constant3 = pvr_pds_get_constants(&next_constant, 1, &data_size); |
| 3265 |
|
| 3266 |
control_word_constant1 = |
| 3267 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 3268 |
control_word_constant2 = |
| 3269 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 3270 |
color_constant4 = pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 3271 |
|
| 3272 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 3273 |
uint32_t doutw; |
| 3274 |
|
| 3275 |
pvr_pds_write_constant32(constants, |
| 3276 |
color_constant1, |
| 3277 |
program->clear_color[0]); |
| 3278 |
|
| 3279 |
pvr_pds_write_constant64(constants, |
| 3280 |
color_constant2, |
| 3281 |
program->clear_color[1], |
| 3282 |
program->clear_color[2]); |
| 3283 |
|
| 3284 |
pvr_pds_write_constant32(constants, |
| 3285 |
color_constant3, |
| 3286 |
program->clear_color[3]); |
| 3287 |
|
| 3288 |
/* Load into first constant in common store. */ |
| 3289 |
doutw = pvr_pds_encode_doutw_src1( |
| 3290 |
program->clear_color_dest_reg, |
| 3291 |
PVR_PDS_DOUTW_LOWER32, |
| 3292 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_COMMON_STORE, |
| 3293 |
false, |
| 3294 |
dev_info); |
| 3295 |
|
| 3296 |
pvr_pds_write_constant64(constants, |
| 3297 |
control_word_constant1, |
| 3298 |
doutw, |
| 3299 |
0); |
| 3300 |
|
| 3301 |
/* Move the destination register along. */ |
| 3302 |
doutw = pvr_pds_encode_doutw_src1( |
| 3303 |
program->clear_color_dest_reg + 1, |
| 3304 |
PVR_PDS_DOUTW_LOWER64, |
| 3305 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_COMMON_STORE, |
| 3306 |
false, |
| 3307 |
dev_info); |
| 3308 |
|
| 3309 |
pvr_pds_write_constant64(constants, |
| 3310 |
control_word_constant2, |
| 3311 |
doutw, |
| 3312 |
0); |
| 3313 |
|
| 3314 |
/* Move the destination register along. */ |
| 3315 |
doutw = pvr_pds_encode_doutw_src1( |
| 3316 |
program->clear_color_dest_reg + 3, |
| 3317 |
PVR_PDS_DOUTW_LOWER32, |
| 3318 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_COMMON_STORE, |
| 3319 |
false, |
| 3320 |
dev_info); |
| 3321 |
|
| 3322 |
/* Set the last flag. */ |
| 3323 |
doutw |= PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_LAST_EN; |
| 3324 |
pvr_pds_write_constant64(constants, color_constant4, doutw, 0); |
| 3325 |
} |
| 3326 |
} else { |
| 3327 |
uint32_t control_word_constant, control_word_last_constant; |
| 3328 |
|
| 3329 |
/* Put the clear color and control words into the first 8 |
| 3330 |
* constants. |
| 3331 |
*/ |
| 3332 |
color_constant1 = pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 3333 |
color_constant2 = pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 3334 |
control_word_constant = |
| 3335 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 3336 |
control_word_last_constant = |
| 3337 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 3338 |
|
| 3339 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 3340 |
uint32_t doutw; |
| 3341 |
pvr_pds_write_constant64(constants, |
| 3342 |
color_constant1, |
| 3343 |
program->clear_color[0], |
| 3344 |
program->clear_color[1]); |
| 3345 |
|
| 3346 |
pvr_pds_write_constant64(constants, |
| 3347 |
color_constant2, |
| 3348 |
program->clear_color[2], |
| 3349 |
program->clear_color[3]); |
| 3350 |
|
| 3351 |
/* Load into first constant in common store. */ |
| 3352 |
doutw = pvr_pds_encode_doutw_src1( |
| 3353 |
program->clear_color_dest_reg, |
| 3354 |
PVR_PDS_DOUTW_LOWER64, |
| 3355 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_COMMON_STORE, |
| 3356 |
false, |
| 3357 |
dev_info); |
| 3358 |
|
| 3359 |
pvr_pds_write_constant64(constants, control_word_constant, doutw, 0); |
| 3360 |
|
| 3361 |
/* Move the destination register along. */ |
| 3362 |
doutw &= PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_AO_CLRMSK; |
| 3363 |
doutw |= (program->clear_color_dest_reg + 2) |
| 3364 |
<< PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_AO_SHIFT; |
| 3365 |
|
| 3366 |
/* Set the last flag. */ |
| 3367 |
doutw |= PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_LAST_EN; |
| 3368 |
pvr_pds_write_constant64(constants, |
| 3369 |
control_word_last_constant, |
| 3370 |
doutw, |
| 3371 |
0); |
| 3372 |
} |
| 3373 |
} |
| 3374 |
|
| 3375 |
/* Constants for the DOUTU Task Control, if needed. */ |
| 3376 |
if (program->kick_usc) { |
| 3377 |
uint32_t doutu_constant64 = |
| 3378 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 3379 |
|
| 3380 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 3381 |
pvr_pds_write_wide_constant( |
| 3382 |
constants, |
| 3383 |
doutu_constant64, |
| 3384 |
program->usc_task_control.src0); /* 64-bit |
| 3385 |
*/ |
| 3386 |
/* Src0 */ |
| 3387 |
} |
| 3388 |
} |
| 3389 |
} else { |
| 3390 |
if (uniform) { |
| 3391 |
/* Reserve space at the beginning of the data segment for the DOUTU |
| 3392 |
* Task Control if one is needed. |
| 3393 |
*/ |
| 3394 |
if (program->kick_usc) { |
| 3395 |
uint32_t doutu_constant64 = |
| 3396 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 3397 |
|
| 3398 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 3399 |
pvr_pds_write_wide_constant( |
| 3400 |
constants, |
| 3401 |
doutu_constant64, |
| 3402 |
program->usc_task_control.src0); /* 64-bit Src0 */ |
| 3403 |
} |
| 3404 |
} |
| 3405 |
|
| 3406 |
uint32_t total_num_doutw = |
| 3407 |
program->num_dword_doutw + program->num_q_word_doutw; |
| 3408 |
uint32_t total_size_dma = |
| 3409 |
program->num_dword_doutw + 2 * program->num_q_word_doutw; |
| 3410 |
|
| 3411 |
/* Allocate 3 constant spaces for each kick. The 64-bit constants |
| 3412 |
* come first followed by the 32-bit constants. |
| 3413 |
*/ |
| 3414 |
uint32_t dma_address_constant64 = |
| 3415 |
pvr_pds_get_constants(&next_constant, |
| 3416 |
program->num_uniform_dma_kicks * 3 + |
| 3417 |
total_size_dma + total_num_doutw, |
| 3418 |
&data_size); |
| 3419 |
uint32_t doutw_value_constant64 = |
| 3420 |
dma_address_constant64 + program->num_uniform_dma_kicks * 2; |
| 3421 |
uint32_t dma_control_constant32 = |
| 3422 |
doutw_value_constant64 + total_size_dma; |
| 3423 |
uint32_t doutw_control_constant32 = |
| 3424 |
dma_control_constant32 + program->num_uniform_dma_kicks; |
| 3425 |
|
| 3426 |
if (total_num_doutw > 0) { |
| 3427 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 3428 |
for (uint32_t i = 0; i < program->num_q_word_doutw; i++) { |
| 3429 |
pvr_pds_write_constant64( |
| 3430 |
constants, |
| 3431 |
doutw_value_constant64, |
| 3432 |
program->q_word_doutw_value[2 * i], |
| 3433 |
program->q_word_doutw_value[2 * i + 1]); |
| 3434 |
pvr_pds_write_constant32( |
| 3435 |
constants, |
| 3436 |
doutw_control_constant32, |
| 3437 |
program->q_word_doutw_control[i] | |
| 3438 |
((!program->num_uniform_dma_kicks && |
| 3439 |
i == total_num_doutw - 1) |
| 3440 |
? PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_LAST_EN |
| 3441 |
: 0)); |
| 3442 |
|
| 3443 |
doutw_value_constant64 += 2; |
| 3444 |
doutw_control_constant32 += 1; |
| 3445 |
} |
| 3446 |
|
| 3447 |
for (uint32_t i = 0; i < program->num_dword_doutw; i++) { |
| 3448 |
pvr_pds_write_constant32(constants, |
| 3449 |
doutw_value_constant64, |
| 3450 |
program->dword_doutw_value[i]); |
| 3451 |
pvr_pds_write_constant32( |
| 3452 |
constants, |
| 3453 |
doutw_control_constant32, |
| 3454 |
program->dword_doutw_control[i] | |
| 3455 |
((!program->num_uniform_dma_kicks && |
| 3456 |
i == program->num_dword_doutw - 1) |
| 3457 |
? PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_LAST_EN |
| 3458 |
: 0)); |
| 3459 |
|
| 3460 |
doutw_value_constant64 += 1; |
| 3461 |
doutw_control_constant32 += 1; |
| 3462 |
} |
| 3463 |
} |
| 3464 |
} |
| 3465 |
|
| 3466 |
if (program->num_uniform_dma_kicks > 0) { |
| 3467 |
uint32_t kick; |
| 3468 |
|
| 3469 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 3470 |
for (kick = 0; kick < program->num_uniform_dma_kicks - 1; |
| 3471 |
kick++) { |
| 3472 |
/* Copy the dma control words to constants. */ |
| 3473 |
pvr_pds_write_dma_address(constants, |
| 3474 |
dma_address_constant64, |
| 3475 |
program->uniform_dma_address[kick], |
| 3476 |
false, |
| 3477 |
dev_info); |
| 3478 |
pvr_pds_write_constant32(constants, |
| 3479 |
dma_control_constant32, |
| 3480 |
program->uniform_dma_control[kick]); |
| 3481 |
|
| 3482 |
dma_address_constant64 += 2; |
| 3483 |
dma_control_constant32 += 1; |
| 3484 |
} |
| 3485 |
|
| 3486 |
pvr_pds_write_dma_address(constants, |
| 3487 |
dma_address_constant64, |
| 3488 |
program->uniform_dma_address[kick], |
| 3489 |
false, |
| 3490 |
dev_info); |
| 3491 |
pvr_pds_write_constant32( |
| 3492 |
constants, |
| 3493 |
dma_control_constant32, |
| 3494 |
program->uniform_dma_control[kick] | |
| 3495 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTD_SRC1_LAST_EN); |
| 3496 |
} |
| 3497 |
} |
| 3498 |
|
| 3499 |
} else if (program->num_texture_dma_kicks > 0) { |
| 3500 |
/* Allocate 3 constant spaces for each kick. The 64-bit constants |
| 3501 |
* come first followed by the 32-bit constants. |
| 3502 |
*/ |
| 3503 |
uint32_t dma_address_constant64 = |
| 3504 |
pvr_pds_get_constants(&next_constant, |
| 3505 |
program->num_texture_dma_kicks * 3, |
| 3506 |
&data_size); |
| 3507 |
uint32_t dma_control_constant32 = |
| 3508 |
dma_address_constant64 + (program->num_texture_dma_kicks * 2); |
| 3509 |
|
| 3510 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 3511 |
uint32_t kick; |
| 3512 |
for (kick = 0; kick < program->num_texture_dma_kicks - 1; kick++) { |
| 3513 |
/* Copy the DMA control words to constants. */ |
| 3514 |
pvr_pds_write_dma_address(constants, |
| 3515 |
dma_address_constant64, |
| 3516 |
program->texture_dma_address[kick], |
| 3517 |
false, |
| 3518 |
dev_info); |
| 3519 |
|
| 3520 |
pvr_pds_write_constant32(constants, |
| 3521 |
dma_control_constant32, |
| 3522 |
program->texture_dma_control[kick]); |
| 3523 |
|
| 3524 |
dma_address_constant64 += 2; |
| 3525 |
dma_control_constant32 += 1; |
| 3526 |
} |
| 3527 |
|
| 3528 |
pvr_pds_write_dma_address(constants, |
| 3529 |
dma_address_constant64, |
| 3530 |
program->texture_dma_address[kick], |
| 3531 |
false, |
| 3532 |
dev_info); |
| 3533 |
|
| 3534 |
pvr_pds_write_constant32( |
| 3535 |
constants, |
| 3536 |
dma_control_constant32, |
| 3537 |
program->texture_dma_control[kick] | |
| 3538 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTD_SRC1_LAST_EN); |
| 3539 |
} |
| 3540 |
} |
| 3541 |
} |
| 3542 |
|
| 3543 |
/* Save the data segment pointer and size. */ |
| 3544 |
program->data_segment = constants; |
| 3545 |
|
| 3546 |
/* Minimum temp count is 1. */ |
| 3547 |
program->temps_used = MAX2(temps_used, 1); |
| 3548 |
program->data_size = data_size; |
| 3549 |
|
| 3550 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) |
| 3551 |
return (constants + next_constant); |
| 3552 |
else |
| 3553 |
return NULL; |
| 3554 |
} |
| 3555 |
|
| 3556 |
/** |
| 3557 |
* Generates generic DOUTC PDS program. |
| 3558 |
* |
| 3559 |
* \param program Pointer to the PDS kick USC. |
| 3560 |
* \param buffer Pointer to the buffer for the program. |
| 3561 |
* \param gen_mode Either code and data can be generated, or sizes only updated. |
| 3562 |
* \returns Pointer to just beyond the buffer for the code or program segment. |
| 3563 |
*/ |
| 3564 |
uint32_t *pvr_pds_generate_doutc(struct pvr_pds_fence_program *restrict program, |
| 3565 |
uint32_t *restrict buffer, |
| 3566 |
enum pvr_pds_generate_mode gen_mode) |
| 3567 |
{ |
| 3568 |
uint32_t constant = 0; |
| 3569 |
|
| 3570 |
/* Automatically get a data size of 1x 128bit chunks. */ |
| 3571 |
uint32_t data_size = 0, code_size = 0; |
| 3572 |
|
| 3573 |
/* Setup the data part. */ |
| 3574 |
uint32_t *constants = buffer; /* Constants placed at front of buffer. */ |
| 3575 |
uint32_t *instruction = buffer; |
| 3576 |
uint32_t next_constant = PVR_PDS_CONSTANTS_BLOCK_BASE; /* Constants count in |
| 3577 |
* dwords. |
| 3578 |
*/ |
| 3579 |
|
| 3580 |
/* Update the program sizes. */ |
| 3581 |
program->data_size = data_size; |
| 3582 |
program->code_size = code_size; |
| 3583 |
program->data_segment = constants; |
| 3584 |
|
| 3585 |
if (gen_mode == PDS_GENERATE_SIZES) |
| 3586 |
return NULL; |
| 3587 |
|
| 3588 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 3589 |
/* Copy the USC task control words to constants. */ |
| 3590 |
|
| 3591 |
constant = pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 3592 |
pvr_pds_write_wide_constant(constants, constant + 0, 0); /* 64-bit |
| 3593 |
* Src0 |
| 3594 |
*/ |
| 3595 |
|
| 3596 |
uint32_t control_word_constant = |
| 3597 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 3598 |
pvr_pds_write_constant64(constants, control_word_constant, 0, 0); /* 32-bit |
| 3599 |
* Src1 |
| 3600 |
*/ |
| 3601 |
|
| 3602 |
program->data_size = data_size; |
| 3603 |
buffer += data_size; |
| 3604 |
|
| 3605 |
return buffer; |
| 3606 |
} else if (gen_mode == PDS_GENERATE_CODE_SEGMENT && instruction) { |
| 3607 |
*instruction++ = pvr_pds_inst_encode_doutc( |
| 3608 |
/* cc */ 0, |
| 3609 |
/* END */ 0); |
| 3610 |
|
| 3611 |
code_size++; |
| 3612 |
|
| 3613 |
/* End the program. */ |
| 3614 |
*instruction++ = pvr_pds_inst_encode_halt(0); |
| 3615 |
code_size++; |
| 3616 |
|
| 3617 |
program->code_size = code_size; |
| 3618 |
} |
| 3619 |
|
| 3620 |
return instruction; |
| 3621 |
} |
| 3622 |
|
| 3623 |
/** |
| 3624 |
* Generates generic kick DOUTU PDS program in a single data+code block. |
| 3625 |
* |
| 3626 |
* \param control Pointer to the PDS kick USC. |
| 3627 |
* \param buffer Pointer to the buffer for the program. |
| 3628 |
* \param gen_mode Either code and data can be generated or sizes only updated. |
| 3629 |
* \param dev_info PVR device information structure. |
| 3630 |
* \returns Pointer to just beyond the buffer for the code or program segment. |
| 3631 |
*/ |
| 3632 |
uint32_t *pvr_pds_generate_doutw(struct pvr_pds_doutw_control *restrict control, |
| 3633 |
uint32_t *restrict buffer, |
| 3634 |
enum pvr_pds_generate_mode gen_mode, |
| 3635 |
const struct pvr_device_info *dev_info) |
| 3636 |
{ |
| 3637 |
uint32_t next_constant = PVR_PDS_CONSTANTS_BLOCK_BASE; |
| 3638 |
uint32_t doutw; |
| 3639 |
uint32_t data_size = 0, code_size = 0; |
| 3640 |
uint32_t constant[PVR_PDS_MAX_NUM_DOUTW_CONSTANTS]; |
| 3641 |
uint32_t control_word_constant[PVR_PDS_MAX_NUM_DOUTW_CONSTANTS]; |
| 3642 |
|
| 3643 |
/* Assert if buffer is exceeded. */ |
| 3644 |
assert(control->num_const64 <= PVR_PDS_MAX_NUM_DOUTW_CONSTANTS); |
| 3645 |
|
| 3646 |
uint32_t *constants = buffer; |
| 3647 |
uint32_t *instruction = buffer; |
| 3648 |
|
| 3649 |
/* Put the constants and control words interleaved in the data region. */ |
| 3650 |
for (uint32_t const_pair = 0; const_pair < control->num_const64; |
| 3651 |
const_pair++) { |
| 3652 |
constant[const_pair] = |
| 3653 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 3654 |
control_word_constant[const_pair] = |
| 3655 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 3656 |
} |
| 3657 |
|
| 3658 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 3659 |
/* Data segment points to start of constants. */ |
| 3660 |
control->data_segment = constants; |
| 3661 |
|
| 3662 |
for (uint32_t const_pair = 0; const_pair < control->num_const64; |
| 3663 |
const_pair++) { |
| 3664 |
pvr_pds_write_constant64(constants, |
| 3665 |
constant[const_pair], |
| 3666 |
H32(control->doutw_data[const_pair]), |
| 3667 |
L32(control->doutw_data[const_pair])); |
| 3668 |
|
| 3669 |
/* Start loading at offset 0. */ |
| 3670 |
if (control->dest_store == PDS_COMMON_STORE) { |
| 3671 |
doutw = pvr_pds_encode_doutw_src1( |
| 3672 |
(2 * const_pair), |
| 3673 |
PVR_PDS_DOUTW_LOWER64, |
| 3674 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_COMMON_STORE, |
| 3675 |
false, |
| 3676 |
dev_info); |
| 3677 |
} else { |
| 3678 |
doutw = pvr_pds_encode_doutw_src1( |
| 3679 |
(2 * const_pair), |
| 3680 |
PVR_PDS_DOUTW_LOWER64, |
| 3681 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_DEST_UNIFIED_STORE, |
| 3682 |
false, |
| 3683 |
dev_info); |
| 3684 |
} |
| 3685 |
|
| 3686 |
if (const_pair + 1 == control->num_const64) { |
| 3687 |
/* Set the last flag for the MCU (assume there are no following |
| 3688 |
* DOUTD's). |
| 3689 |
*/ |
| 3690 |
doutw |= PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTW_SRC1_LAST_EN; |
| 3691 |
} |
| 3692 |
pvr_pds_write_constant64(constants, |
| 3693 |
control_word_constant[const_pair], |
| 3694 |
doutw, |
| 3695 |
0); |
| 3696 |
} |
| 3697 |
|
| 3698 |
control->data_size = data_size; |
| 3699 |
} else if (gen_mode == PDS_GENERATE_CODE_SEGMENT && instruction) { |
| 3700 |
/* Code section. */ |
| 3701 |
|
| 3702 |
for (uint32_t const_pair = 0; const_pair < control->num_const64; |
| 3703 |
const_pair++) { |
| 3704 |
/* DOUTW the PDS data to the USC constants. */ |
| 3705 |
*instruction++ = pvr_pds_encode_doutw64( |
| 3706 |
/* cc */ 0, |
| 3707 |
/* END */ control->last_instruction && |
| 3708 |
(const_pair + 1 == control->num_const64), |
| 3709 |
/* SRC1 */ control_word_constant[const_pair], /* DOUTW 32-bit |
| 3710 |
* Src1. |
| 3711 |
*/ |
| 3712 |
/* SRC0 */ constant[const_pair] >> 1); /* DOUTW 64-bit Src0. */ |
| 3713 |
|
| 3714 |
code_size++; |
| 3715 |
} |
| 3716 |
|
| 3717 |
if (control->last_instruction) { |
| 3718 |
/* End the program. */ |
| 3719 |
*instruction++ = pvr_pds_inst_encode_halt(0); |
| 3720 |
code_size++; |
| 3721 |
} |
| 3722 |
|
| 3723 |
control->code_size = code_size; |
| 3724 |
} |
| 3725 |
|
| 3726 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) |
| 3727 |
return (constants + next_constant); |
| 3728 |
else |
| 3729 |
return instruction; |
| 3730 |
} |
| 3731 |
|
| 3732 |
/** |
| 3733 |
* Generates generic kick DOUTU PDS program in a single data+code block. |
| 3734 |
* |
| 3735 |
* \param program Pointer to the PDS kick USC. |
| 3736 |
* \param buffer Pointer to the buffer for the program. |
| 3737 |
* \param start_next_constant Next constant in data segment. Non-zero if another |
| 3738 |
* instruction precedes the DOUTU. |
| 3739 |
* \param cc_enabled If true then the DOUTU is predicated (cc set). |
| 3740 |
* \param gen_mode Either code and data can be generated or sizes only updated. |
| 3741 |
* \returns Pointer to just beyond the buffer for the code or program segment. |
| 3742 |
*/ |
| 3743 |
uint32_t *pvr_pds_kick_usc(struct pvr_pds_kickusc_program *restrict program, |
| 3744 |
uint32_t *restrict buffer, |
| 3745 |
uint32_t start_next_constant, |
| 3746 |
bool cc_enabled, |
| 3747 |
enum pvr_pds_generate_mode gen_mode) |
| 3748 |
{ |
| 3749 |
uint32_t constant = 0; |
| 3750 |
|
| 3751 |
/* Automatically get a data size of 2 128bit chunks. */ |
| 3752 |
uint32_t data_size = ROGUE_PDS_FIXED_PIXEL_SHADER_DATA_SIZE; |
| 3753 |
uint32_t code_size = 1; /* Single doutu */ |
| 3754 |
uint32_t dummy_count = 0; |
| 3755 |
|
| 3756 |
/* Setup the data part. */ |
| 3757 |
uint32_t *constants = buffer; /* Constants placed at front of buffer. */ |
| 3758 |
uint32_t next_constant = PVR_PDS_CONSTANTS_BLOCK_BASE; /* Constants count in |
| 3759 |
* dwords. |
| 3760 |
*/ |
| 3761 |
|
| 3762 |
/* Update the program sizes. */ |
| 3763 |
program->data_size = data_size; |
| 3764 |
program->code_size = code_size; |
| 3765 |
program->data_segment = constants; |
| 3766 |
|
| 3767 |
if (gen_mode == PDS_GENERATE_SIZES) |
| 3768 |
return NULL; |
| 3769 |
|
| 3770 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT || |
| 3771 |
gen_mode == PDS_GENERATE_CODEDATA_SEGMENTS) { |
| 3772 |
/* Copy the USC task control words to constants. */ |
| 3773 |
|
| 3774 |
constant = pvr_pds_get_constants(&next_constant, 2, &dummy_count); |
| 3775 |
program->doutu_offset = constant; |
| 3776 |
|
| 3777 |
pvr_pds_write_wide_constant(constants, |
| 3778 |
constant + 0, |
| 3779 |
program->usc_task_control.src0); /* 64-bit |
| 3780 |
* Src0. |
| 3781 |
*/ |
| 3782 |
buffer += data_size; |
| 3783 |
|
| 3784 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) |
| 3785 |
return buffer; |
| 3786 |
} |
| 3787 |
|
| 3788 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT || |
| 3789 |
gen_mode == PDS_GENERATE_CODEDATA_SEGMENTS) { |
| 3790 |
/* Generate the PDS pixel shader code. */ |
| 3791 |
|
| 3792 |
/* Setup the instruction pointer. */ |
| 3793 |
uint32_t *instruction = buffer; |
| 3794 |
|
| 3795 |
/* Issue the task to the USC. |
| 3796 |
* |
| 3797 |
* dout ds1[constant_use], ds0[constant_use], ds1[constant_use], emit ; |
| 3798 |
* halt halt |
| 3799 |
*/ |
| 3800 |
|
| 3801 |
*instruction++ = pvr_pds_encode_doutu( |
| 3802 |
/* cc */ cc_enabled, |
| 3803 |
/* END */ 1, |
| 3804 |
/* SRC0 */ (constant + start_next_constant) >> 1); /* DOUTU |
| 3805 |
* 64-bit Src0 |
| 3806 |
*/ |
| 3807 |
|
| 3808 |
/* Return pointer to just after last instruction. */ |
| 3809 |
return instruction; |
| 3810 |
} |
| 3811 |
|
| 3812 |
/* Execution should never reach here; keep compiler happy. */ |
| 3813 |
return NULL; |
| 3814 |
} |
| 3815 |
|
| 3816 |
uint32_t *pvr_pds_generate_compute_barrier_conditional( |
| 3817 |
uint32_t *buffer, |
| 3818 |
enum pvr_pds_generate_mode gen_mode) |
| 3819 |
{ |
| 3820 |
/* Compute barriers supported. Need to test for coeff sync task. */ |
| 3821 |
|
| 3822 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) |
| 3823 |
return buffer; /* No data segment. */ |
| 3824 |
|
| 3825 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 3826 |
/* Test whether this is the coefficient update task or not. */ |
| 3827 |
*buffer++ = pvr_pds_encode_bra(PVR_ROGUE_PDSINST_PREDICATE_IF0, /* SRCC |
| 3828 |
*/ |
| 3829 |
PVR_ROGUE_PDSINST_BRA_NEG_DISABLE, /* NEG |
| 3830 |
*/ |
| 3831 |
PVR_ROGUE_PDSINST_PREDICATE_IF1, /* SETC |
| 3832 |
*/ |
| 3833 |
1 /* ADDR */); |
| 3834 |
|
| 3835 |
/* Encode a HALT. */ |
| 3836 |
*buffer++ = pvr_pds_inst_encode_halt(1); |
| 3837 |
|
| 3838 |
/* Reset the default predicate to IF0. */ |
| 3839 |
*buffer++ = pvr_pds_encode_bra(PVR_ROGUE_PDSINST_PREDICATE_IF0, /* SRCC |
| 3840 |
*/ |
| 3841 |
PVR_ROGUE_PDSINST_BRA_NEG_DISABLE, /* NEG |
| 3842 |
*/ |
| 3843 |
PVR_ROGUE_PDSINST_PREDICATE_IF0, /* SETC |
| 3844 |
*/ |
| 3845 |
1 /* ADDR */); |
| 3846 |
} |
| 3847 |
|
| 3848 |
return buffer; |
| 3849 |
} |
| 3850 |
|
| 3851 |
/** |
| 3852 |
* Generates program to kick the USC task to store shared. |
| 3853 |
* |
| 3854 |
* \param program Pointer to the PDS shared register. |
| 3855 |
* \param buffer Pointer to the buffer for the program. |
| 3856 |
* \param gen_mode Either code and data can be generated or sizes only updated. |
| 3857 |
* \param dev_info PVR device information structure. |
| 3858 |
* \returns Pointer to just beyond the buffer for the program. |
| 3859 |
*/ |
| 3860 |
uint32_t *pvr_pds_generate_shared_storing_program( |
| 3861 |
struct pvr_pds_shared_storing_program *restrict program, |
| 3862 |
uint32_t *restrict buffer, |
| 3863 |
enum pvr_pds_generate_mode gen_mode, |
| 3864 |
const struct pvr_device_info *dev_info) |
| 3865 |
{ |
| 3866 |
struct pvr_pds_kickusc_program *kick_usc_program = &program->usc_task; |
| 3867 |
struct pvr_pds_doutw_control *doutw_control = &program->doutw_control; |
| 3868 |
|
| 3869 |
if (gen_mode == PDS_GENERATE_SIZES) |
| 3870 |
return NULL; |
| 3871 |
|
| 3872 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 3873 |
uint32_t *constants = buffer; |
| 3874 |
|
| 3875 |
constants = |
| 3876 |
pvr_pds_generate_doutw(doutw_control, constants, gen_mode, dev_info); |
| 3877 |
program->data_size = doutw_control->data_size; |
| 3878 |
|
| 3879 |
constants = pvr_pds_kick_usc(kick_usc_program, |
| 3880 |
constants, |
| 3881 |
0, |
| 3882 |
program->cc_enable, |
| 3883 |
gen_mode); |
| 3884 |
program->data_size += kick_usc_program->data_size; |
| 3885 |
|
| 3886 |
return constants; |
| 3887 |
} |
| 3888 |
|
| 3889 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 3890 |
/* Generate PDS code segment. */ |
| 3891 |
uint32_t *instruction = buffer; |
| 3892 |
|
| 3893 |
/* doutw vi1, vi0 |
| 3894 |
* doutu ds1[constant_use], ds0[constant_use], ds1[constant_use], |
| 3895 |
* emit |
| 3896 |
*/ |
| 3897 |
instruction = |
| 3898 |
pvr_pds_generate_doutw(doutw_control, buffer, gen_mode, dev_info); |
| 3899 |
program->code_size = doutw_control->code_size; |
| 3900 |
|
| 3901 |
/* Offset into data segment follows on from doutw data segment. */ |
| 3902 |
instruction = pvr_pds_kick_usc(kick_usc_program, |
| 3903 |
instruction, |
| 3904 |
doutw_control->data_size, |
| 3905 |
program->cc_enable, |
| 3906 |
gen_mode); |
| 3907 |
program->code_size += kick_usc_program->code_size; |
| 3908 |
|
| 3909 |
return instruction; |
| 3910 |
} |
| 3911 |
|
| 3912 |
/* Execution should never reach here. */ |
| 3913 |
return NULL; |
| 3914 |
} |
| 3915 |
|
| 3916 |
uint32_t *pvr_pds_generate_fence_terminate_program( |
| 3917 |
struct pvr_pds_fence_program *restrict program, |
| 3918 |
uint32_t *restrict buffer, |
| 3919 |
enum pvr_pds_generate_mode gen_mode, |
| 3920 |
const struct pvr_device_info *dev_info) |
| 3921 |
{ |
| 3922 |
uint32_t data_size = 0; |
| 3923 |
uint32_t code_size = 0; |
| 3924 |
|
| 3925 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 3926 |
/* Data segment. */ |
| 3927 |
uint32_t *constants, *constants_base; |
| 3928 |
|
| 3929 |
constants = constants_base = (uint32_t *)buffer; |
| 3930 |
|
| 3931 |
/* DOUTC sources are not used, but they must be valid. */ |
| 3932 |
pvr_pds_generate_doutc(program, constants, PDS_GENERATE_DATA_SEGMENT); |
| 3933 |
data_size += program->data_size; |
| 3934 |
|
| 3935 |
if (PVR_NEED_SW_COMPUTE_PDS_BARRIER(dev_info)) { |
| 3936 |
/* Append a 64-bit constant with value 1. Used to increment ptemp. |
| 3937 |
* Return the offset into the data segment. |
| 3938 |
*/ |
| 3939 |
program->fence_constant_word = |
| 3940 |
pvr_pds_append_constant64(constants_base, 1, &data_size); |
| 3941 |
} |
| 3942 |
|
| 3943 |
program->data_size = data_size; |
| 3944 |
return constants; |
| 3945 |
} |
| 3946 |
|
| 3947 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 3948 |
/* Code segment. */ |
| 3949 |
uint32_t *instruction = (uint32_t *)buffer; |
| 3950 |
|
| 3951 |
instruction = pvr_pds_generate_compute_barrier_conditional( |
| 3952 |
instruction, |
| 3953 |
PDS_GENERATE_CODE_SEGMENT); |
| 3954 |
code_size += 3; |
| 3955 |
|
| 3956 |
if (PVR_NEED_SW_COMPUTE_PDS_BARRIER(dev_info)) { |
| 3957 |
/* lock */ |
| 3958 |
*instruction++ = pvr_pds_inst_encode_lock(0); /* cc */ |
| 3959 |
|
| 3960 |
/* add64 pt[0], pt[0], #1 */ |
| 3961 |
*instruction++ = pvr_pds_inst_encode_add64( |
| 3962 |
0, /* cc */ |
| 3963 |
PVR_ROGUE_PDSINST_ALUM_UNSIGNED, |
| 3964 |
PVR_ROGUE_PDSINST_MAD_SNA_ADD, |
| 3965 |
PVR_ROGUE_PDSINST_REGS64_PTEMP64_LOWER + 0, /* src0 = ptemp[0] |
| 3966 |
*/ |
| 3967 |
PVR_ROGUE_PDSINST_REGS64_CONST64_LOWER + |
| 3968 |
(program->fence_constant_word >> 1), /* src1 = 1 */ |
| 3969 |
PVR_ROGUE_PDSINST_REGS64TP_PTEMP64_LOWER + 0); /* dest = |
| 3970 |
* ptemp[0] |
| 3971 |
*/ |
| 3972 |
|
| 3973 |
/* release */ |
| 3974 |
*instruction++ = pvr_pds_inst_encode_release(0); /* cc */ |
| 3975 |
|
| 3976 |
/* cmp pt[0] EQ 0x4 == Number of USC clusters per phantom */ |
| 3977 |
*instruction++ = pvr_pds_inst_encode_cmpi( |
| 3978 |
0, /* cc */ |
| 3979 |
PVR_ROGUE_PDSINST_COP_EQ, |
| 3980 |
PVR_ROGUE_PDSINST_REGS64TP_PTEMP64_LOWER + 0, /* src0 |
| 3981 |
* = ptemp[0] |
| 3982 |
*/ |
| 3983 |
PVR_GET_FEATURE_VALUE(dev_info, num_clusters, 0)); |
| 3984 |
|
| 3985 |
/* bra -1 */ |
| 3986 |
*instruction++ = |
| 3987 |
pvr_pds_encode_bra(0, /* cc */ |
| 3988 |
1, /* PVR_ROGUE_PDSINST_BRA_NEG_ENABLE |
| 3989 |
*/ |
| 3990 |
0, /* PVR_ROGUE_PDSINST_BRA_SETC_P0 |
| 3991 |
*/ |
| 3992 |
-1); /* bra PC */ |
| 3993 |
code_size += 5; |
| 3994 |
} |
| 3995 |
|
| 3996 |
/* DOUTC */ |
| 3997 |
instruction = pvr_pds_generate_doutc(program, |
| 3998 |
instruction, |
| 3999 |
PDS_GENERATE_CODE_SEGMENT); |
| 4000 |
code_size += program->code_size; |
| 4001 |
|
| 4002 |
program->code_size = code_size; |
| 4003 |
return instruction; |
| 4004 |
} |
| 4005 |
|
| 4006 |
/* Execution should never reach here. */ |
| 4007 |
return NULL; |
| 4008 |
} |
| 4009 |
|
| 4010 |
/** |
| 4011 |
* Generates program to kick the USC task to load shared registers from memory. |
| 4012 |
* |
| 4013 |
* \param program Pointer to the PDS shared register. |
| 4014 |
* \param buffer Pointer to the buffer for the program. |
| 4015 |
* \param gen_mode Either code and data can be generated or sizes only updated. |
| 4016 |
* \param dev_info PVR device information struct. |
| 4017 |
* \returns Pointer to just beyond the buffer for the program. |
| 4018 |
*/ |
| 4019 |
uint32_t *pvr_pds_generate_compute_shared_loading_program( |
| 4020 |
struct pvr_pds_shared_storing_program *restrict program, |
| 4021 |
uint32_t *restrict buffer, |
| 4022 |
enum pvr_pds_generate_mode gen_mode, |
| 4023 |
const struct pvr_device_info *dev_info) |
| 4024 |
{ |
| 4025 |
struct pvr_pds_kickusc_program *kick_usc_program = &program->usc_task; |
| 4026 |
struct pvr_pds_doutw_control *doutw_control = &program->doutw_control; |
| 4027 |
|
| 4028 |
uint32_t next_constant; |
| 4029 |
uint32_t data_size = 0; |
| 4030 |
uint32_t code_size = 0; |
| 4031 |
|
| 4032 |
/* This needs to persist to the CODE_SEGMENT call. */ |
| 4033 |
static uint32_t fence_constant_word = 0; |
| 4034 |
uint64_t zero_constant64 = 0; |
| 4035 |
|
| 4036 |
if (gen_mode == PDS_GENERATE_SIZES) |
| 4037 |
return NULL; |
| 4038 |
|
| 4039 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 4040 |
uint32_t *constants = buffer; |
| 4041 |
|
| 4042 |
constants = pvr_pds_generate_doutw(doutw_control, |
| 4043 |
constants, |
| 4044 |
PDS_GENERATE_DATA_SEGMENT, |
| 4045 |
dev_info); |
| 4046 |
data_size += doutw_control->data_size; |
| 4047 |
|
| 4048 |
constants = pvr_pds_kick_usc(kick_usc_program, |
| 4049 |
constants, |
| 4050 |
0, |
| 4051 |
program->cc_enable, |
| 4052 |
gen_mode); |
| 4053 |
data_size += kick_usc_program->data_size; |
| 4054 |
|
| 4055 |
/* Copy the fence constant value (64-bit). */ |
| 4056 |
next_constant = data_size; /* Assumes data words fully packed. */ |
| 4057 |
fence_constant_word = |
| 4058 |
pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 4059 |
|
| 4060 |
/* Encode the fence constant src0 (offset measured from start of data |
| 4061 |
* buffer). Fence barrier is initialized to zero. |
| 4062 |
*/ |
| 4063 |
pvr_pds_write_wide_constant(buffer, fence_constant_word, zero_constant64); |
| 4064 |
/* Update the const size. */ |
| 4065 |
data_size += 2; |
| 4066 |
constants += 2; |
| 4067 |
|
| 4068 |
program->data_size = data_size; |
| 4069 |
return constants; |
| 4070 |
} |
| 4071 |
|
| 4072 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 4073 |
/* Generate PDS code segment. */ |
| 4074 |
uint32_t *instruction = buffer; |
| 4075 |
|
| 4076 |
/* add64 pt0, c0, c0 |
| 4077 |
* IF [2x Phantoms] |
| 4078 |
* add64 pt1, c0, c0 |
| 4079 |
* st [constant_mem_addr], pt0, 4 |
| 4080 |
* ENDIF |
| 4081 |
* doutw vi1, vi0 |
| 4082 |
* doutu ds1[constant_use], ds0[constant_use], ds1[constant_use], |
| 4083 |
* emit |
| 4084 |
* |
| 4085 |
* Zero the persistent temp (SW fence for context switch). |
| 4086 |
*/ |
| 4087 |
*instruction++ = pvr_pds_inst_encode_add64( |
| 4088 |
0, /* cc */ |
| 4089 |
PVR_ROGUE_PDSINST_ALUM_UNSIGNED, |
| 4090 |
PVR_ROGUE_PDSINST_MAD_SNA_ADD, |
| 4091 |
PVR_ROGUE_PDSINST_REGS64_CONST64_LOWER + |
| 4092 |
(fence_constant_word >> 1), /* src0 |
| 4093 |
* = 0 |
| 4094 |
*/ |
| 4095 |
PVR_ROGUE_PDSINST_REGS64_CONST64_LOWER + |
| 4096 |
(fence_constant_word >> 1), /* src1 |
| 4097 |
* = 0 |
| 4098 |
*/ |
| 4099 |
PVR_ROGUE_PDSINST_REGS64TP_PTEMP64_LOWER + 0); /* dest = ptemp64[0] |
| 4100 |
*/ |
| 4101 |
code_size++; |
| 4102 |
|
| 4103 |
instruction = pvr_pds_generate_doutw(doutw_control, |
| 4104 |
instruction, |
| 4105 |
PDS_GENERATE_CODE_SEGMENT, |
| 4106 |
dev_info); |
| 4107 |
code_size += doutw_control->code_size; |
| 4108 |
|
| 4109 |
/* Offset into data segment follows on from doutw data segment. */ |
| 4110 |
instruction = pvr_pds_kick_usc(kick_usc_program, |
| 4111 |
instruction, |
| 4112 |
doutw_control->data_size, |
| 4113 |
program->cc_enable, |
| 4114 |
gen_mode); |
| 4115 |
code_size += kick_usc_program->code_size; |
| 4116 |
|
| 4117 |
program->code_size = code_size; |
| 4118 |
return instruction; |
| 4119 |
} |
| 4120 |
|
| 4121 |
/* Execution should never reach here. */ |
| 4122 |
return NULL; |
| 4123 |
} |
| 4124 |
|
| 4125 |
/** |
| 4126 |
* Generates both code and data when gen_mode is not PDS_GENERATE_SIZES. |
| 4127 |
* Relies on num_fpu_iterators being initialized for size calculation. |
| 4128 |
* Relies on num_fpu_iterators, destination[], and FPU_iterators[] being |
| 4129 |
* initialized for program generation. |
| 4130 |
* |
| 4131 |
* \param program Pointer to the PDS pixel shader program. |
| 4132 |
* \param buffer Pointer to the buffer for the program. |
| 4133 |
* \param gen_mode Either code and data can be generated or sizes only updated. |
| 4134 |
* \returns Pointer to just beyond the buffer for the program. |
| 4135 |
*/ |
| 4136 |
uint32_t *pvr_pds_coefficient_loading( |
| 4137 |
struct pvr_pds_coeff_loading_program *restrict program, |
| 4138 |
uint32_t *restrict buffer, |
| 4139 |
enum pvr_pds_generate_mode gen_mode) |
| 4140 |
{ |
| 4141 |
uint32_t constant; |
| 4142 |
uint32_t *instruction; |
| 4143 |
uint32_t total_data_size, code_size; |
| 4144 |
|
| 4145 |
/* Place constants at the front of the buffer. */ |
| 4146 |
uint32_t *constants = buffer; |
| 4147 |
/* Start counting constants from 0. */ |
| 4148 |
uint32_t next_constant = PVR_PDS_CONSTANTS_BLOCK_BASE; |
| 4149 |
|
| 4150 |
/* Save the data segment pointer and size. */ |
| 4151 |
program->data_segment = constants; |
| 4152 |
|
| 4153 |
total_data_size = 0; |
| 4154 |
code_size = 0; |
| 4155 |
|
| 4156 |
total_data_size += 2 * program->num_fpu_iterators; |
| 4157 |
code_size += program->num_fpu_iterators; |
| 4158 |
|
| 4159 |
/* Instructions start where constants finished, but we must take note of |
| 4160 |
* alignment. |
| 4161 |
* |
| 4162 |
* 128-bit boundary = 4 dwords. |
| 4163 |
*/ |
| 4164 |
total_data_size = ALIGN_POT(total_data_size, 4); |
| 4165 |
if (gen_mode != PDS_GENERATE_SIZES) { |
| 4166 |
uint32_t data_size = 0; |
| 4167 |
uint32_t iterator = 0; |
| 4168 |
|
| 4169 |
instruction = buffer + total_data_size; |
| 4170 |
|
| 4171 |
while (iterator < program->num_fpu_iterators) { |
| 4172 |
uint64_t iterator_word; |
| 4173 |
|
| 4174 |
/* Copy the USC task control words to constants. */ |
| 4175 |
constant = pvr_pds_get_constants(&next_constant, 2, &data_size); |
| 4176 |
|
| 4177 |
if (BITSET_TEST(program->flat_iter_mask, iterator)) |
| 4178 |
program->dout_src_offsets[iterator] = constant; |
| 4179 |
else |
| 4180 |
program->dout_src_offsets[iterator] = ~0u; |
| 4181 |
|
| 4182 |
if (program->z_iterator == ~0u) |
| 4183 |
program->dout_z_iterator_offset = ~0u; |
| 4184 |
else if (program->z_iterator == iterator) |
| 4185 |
program->dout_z_iterator_offset = constant; |
| 4186 |
|
| 4187 |
/* Write the first iterator. */ |
| 4188 |
iterator_word = |
| 4189 |
(uint64_t)program->FPU_iterators[iterator] |
| 4190 |
<< PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTI_SRC0_ISSUE0_SHIFT; |
| 4191 |
|
| 4192 |
/* Write the destination. */ |
| 4193 |
iterator_word |= |
| 4194 |
(uint64_t)program->destination[iterator++] |
| 4195 |
<< PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTI_SRC0_DEST_SHIFT; |
| 4196 |
|
| 4197 |
/* If this is the last DOUTI word the "Last Issue" bit should be |
| 4198 |
* set. |
| 4199 |
*/ |
| 4200 |
if (iterator >= program->num_fpu_iterators) { |
| 4201 |
iterator_word |= PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTI_SRC0_ISSUE_EN; |
| 4202 |
} |
| 4203 |
|
| 4204 |
/* Write the word to the buffer. */ |
| 4205 |
pvr_pds_write_wide_constant(constants, |
| 4206 |
constant, |
| 4207 |
iterator_word); /* 64-bit |
| 4208 |
Src0 |
| 4209 |
*/ |
| 4210 |
|
| 4211 |
/* Write the DOUT instruction. */ |
| 4212 |
*instruction++ = pvr_pds_encode_douti( |
| 4213 |
/* cc */ 0, |
| 4214 |
/* END */ 0, |
| 4215 |
/* SRC0 */ constant >> 1); /* DOUT Issue word 0 64-bit */ |
| 4216 |
} |
| 4217 |
|
| 4218 |
/* Update the last DOUTI instruction to have the END flag set. */ |
| 4219 |
*(instruction - 1) |= 1 << PVR_ROGUE_PDSINST_DOUT_END_SHIFT; |
| 4220 |
} else { |
| 4221 |
instruction = NULL; |
| 4222 |
} |
| 4223 |
|
| 4224 |
/* Update the data size and code size. Minimum temp count is 1. */ |
| 4225 |
program->temps_used = 1; |
| 4226 |
program->data_size = total_data_size; |
| 4227 |
program->code_size = code_size; |
| 4228 |
|
| 4229 |
return instruction; |
| 4230 |
} |
| 4231 |
|
| 4232 |
/** |
| 4233 |
* Generate a single ld/st instruction. This can correspond to one or more |
| 4234 |
* real ld/st instructions based on the value of count. |
| 4235 |
* |
| 4236 |
* \param ld true to generate load, false to generate store. |
| 4237 |
* \param control Cache mode control. |
| 4238 |
* \param temp_index Dest temp for load/source temp for store, in 32bits |
| 4239 |
* register index. |
| 4240 |
* \param address Source for load/dest for store in bytes. |
| 4241 |
* \param count Number of dwords for load/store. |
| 4242 |
* \param next_constant |
| 4243 |
* \param total_data_size |
| 4244 |
* \param total_code_size |
| 4245 |
* \param buffer Pointer to the buffer for the program. |
| 4246 |
* \param data_fence Issue data fence. |
| 4247 |
* \param gen_mode Either code and data can be generated or sizes only updated. |
| 4248 |
* \param dev_info PVR device information structure. |
| 4249 |
* \returns Pointer to just beyond the buffer for the program. |
| 4250 |
*/ |
| 4251 |
uint32_t *pvr_pds_generate_single_ldst_instruction( |
| 4252 |
bool ld, |
| 4253 |
const struct pvr_pds_ldst_control *control, |
| 4254 |
uint32_t temp_index, |
| 4255 |
uint64_t address, |
| 4256 |
uint32_t count, |
| 4257 |
uint32_t *next_constant, |
| 4258 |
uint32_t *total_data_size, |
| 4259 |
uint32_t *total_code_size, |
| 4260 |
uint32_t *restrict buffer, |
| 4261 |
bool data_fence, |
| 4262 |
enum pvr_pds_generate_mode gen_mode, |
| 4263 |
const struct pvr_device_info *dev_info) |
| 4264 |
{ |
| 4265 |
/* A single ld/ST here does NOT actually correspond to a single ld/ST |
| 4266 |
* instruction, but may needs multiple ld/ST instructions because each ld/ST |
| 4267 |
* instruction can only ld/ST a restricted max number of dwords which may |
| 4268 |
* less than count passed here. |
| 4269 |
*/ |
| 4270 |
|
| 4271 |
uint32_t num_inst; |
| 4272 |
uint32_t constant; |
| 4273 |
|
| 4274 |
if (ld) { |
| 4275 |
/* ld must operate on 64bits unit, and it needs to load from and to 128 |
| 4276 |
* bits aligned. Apart from the last ld, all the other need to ld 2x(x = |
| 4277 |
* 1, 2, ...) times 64bits unit. |
| 4278 |
*/ |
| 4279 |
uint32_t per_inst_count = 0; |
| 4280 |
uint32_t last_inst_count; |
| 4281 |
|
| 4282 |
assert((gen_mode == PDS_GENERATE_SIZES) || |
| 4283 |
(((count % 2) == 0) && ((address % 16) == 0) && |
| 4284 |
(temp_index % 2) == 0)); |
| 4285 |
|
| 4286 |
count >>= 1; |
| 4287 |
temp_index >>= 1; |
| 4288 |
|
| 4289 |
/* Found out how many ld instructions are needed and ld size for the all |
| 4290 |
* possible ld instructions. |
| 4291 |
*/ |
| 4292 |
if (count <= PVR_ROGUE_PDSINST_LD_COUNT8_MAX_SIZE) { |
| 4293 |
num_inst = 1; |
| 4294 |
last_inst_count = count; |
| 4295 |
} else { |
| 4296 |
per_inst_count = PVR_ROGUE_PDSINST_LD_COUNT8_MAX_SIZE; |
| 4297 |
if ((per_inst_count % 2) != 0) |
| 4298 |
per_inst_count -= 1; |
| 4299 |
|
| 4300 |
num_inst = count / per_inst_count; |
| 4301 |
last_inst_count = count - per_inst_count * num_inst; |
| 4302 |
num_inst += 1; |
| 4303 |
} |
| 4304 |
|
| 4305 |
/* Generate all the instructions. */ |
| 4306 |
for (uint32_t i = 0; i < num_inst; i++) { |
| 4307 |
if ((i == (num_inst - 1)) && (last_inst_count == 0)) |
| 4308 |
break; |
| 4309 |
|
| 4310 |
/* A single load instruction. */ |
| 4311 |
constant = pvr_pds_get_constants(next_constant, 2, total_data_size); |
| 4312 |
|
| 4313 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 4314 |
uint64_t ld_src0 = 0; |
| 4315 |
|
| 4316 |
ld_src0 |= (((address >> 2) & PVR_ROGUE_PDSINST_LD_SRCADD_MASK) |
| 4317 |
<< PVR_ROGUE_PDSINST_LD_LD_SRC0_SRCADD_SHIFT); |
| 4318 |
ld_src0 |= (((uint64_t)((i == num_inst - 1) ? last_inst_count |
| 4319 |
: per_inst_count) & |
| 4320 |
PVR_ROGUE_PDSINST_LD_COUNT8_MASK) |
| 4321 |
<< PVR_ROGUE_PDSINST_LD_LD_SRC0_COUNT8_SHIFT); |
| 4322 |
ld_src0 |= (((uint64_t)temp_index & PVR_ROGUE_PDSINST_REGS64TP_MASK) |
| 4323 |
<< PVR_ROGUE_PDSINST_LD_LD_SRC0_DEST_SHIFT); |
| 4324 |
|
| 4325 |
if (!control) { |
| 4326 |
ld_src0 |= PVR_ROGUE_PDSINST_LD_LD_SRC0_CMODE_CACHED; |
| 4327 |
|
| 4328 |
if (PVR_HAS_FEATURE(dev_info, slc_mcu_cache_controls)) |
| 4329 |
ld_src0 |= PVR_ROGUE_PDSINST_LD_LD_SRC0_SLCMODE_CACHED; |
| 4330 |
|
| 4331 |
} else { |
| 4332 |
ld_src0 |= control->cache_control_const; |
| 4333 |
} |
| 4334 |
|
| 4335 |
/* Write it to the constant. */ |
| 4336 |
pvr_pds_write_constant64(buffer, |
| 4337 |
constant, |
| 4338 |
(uint32_t)(ld_src0), |
| 4339 |
(uint32_t)(ld_src0 >> 32)); |
| 4340 |
|
| 4341 |
/* Adjust value for next ld instruction. */ |
| 4342 |
temp_index += per_inst_count; |
| 4343 |
address += (((uint64_t)(per_inst_count)) << 3); |
| 4344 |
} |
| 4345 |
|
| 4346 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 4347 |
*buffer++ = pvr_pds_inst_encode_ld(0, constant >> 1); |
| 4348 |
|
| 4349 |
if (data_fence) |
| 4350 |
*buffer++ = pvr_pds_inst_encode_wdf(0); |
| 4351 |
} |
| 4352 |
} |
| 4353 |
} else { |
| 4354 |
/* ST needs source memory address to be 32bits aligned. */ |
| 4355 |
assert((gen_mode == PDS_GENERATE_SIZES) || ((address % 4) == 0)); |
| 4356 |
|
| 4357 |
/* Found out how many ST instructions are needed, each ST can only store |
| 4358 |
* PVR_ROGUE_PDSINST_ST_COUNT4_MASK number of 32bits. |
| 4359 |
*/ |
| 4360 |
num_inst = count / PVR_ROGUE_PDSINST_ST_COUNT4_MAX_SIZE; |
| 4361 |
num_inst += ((count % PVR_ROGUE_PDSINST_ST_COUNT4_MAX_SIZE) == 0 ? 0 : 1); |
| 4362 |
|
| 4363 |
/* Generate all the instructions. */ |
| 4364 |
for (uint32_t i = 0; i < num_inst; i++) { |
| 4365 |
/* A single store instruction. */ |
| 4366 |
constant = pvr_pds_get_constants(next_constant, 2, total_data_size); |
| 4367 |
|
| 4368 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) { |
| 4369 |
uint32_t per_inst_count = |
| 4370 |
(count <= PVR_ROGUE_PDSINST_ST_COUNT4_MAX_SIZE |
| 4371 |
? count |
| 4372 |
: PVR_ROGUE_PDSINST_ST_COUNT4_MAX_SIZE); |
| 4373 |
uint64_t st_src0 = 0; |
| 4374 |
|
| 4375 |
st_src0 |= (((address >> 2) & PVR_ROGUE_PDSINST_ST_SRCADD_MASK) |
| 4376 |
<< PVR_ROGUE_PDSINST_ST_ST_SRC0_DSTADD_SHIFT); |
| 4377 |
st_src0 |= |
| 4378 |
(((uint64_t)per_inst_count & PVR_ROGUE_PDSINST_ST_COUNT4_MASK) |
| 4379 |
<< PVR_ROGUE_PDSINST_ST_ST_SRC0_COUNT4_SHIFT); |
| 4380 |
st_src0 |= (((uint64_t)temp_index & PVR_ROGUE_PDSINST_REGS32TP_MASK) |
| 4381 |
<< PVR_ROGUE_PDSINST_ST_ST_SRC0_SRC_SHIFT); |
| 4382 |
|
| 4383 |
if (!control) { |
| 4384 |
st_src0 |= PVR_ROGUE_PDSINST_ST_ST_SRC0_CMODE_WRITE_THROUGH; |
| 4385 |
|
| 4386 |
if (PVR_HAS_FEATURE(dev_info, slc_mcu_cache_controls)) { |
| 4387 |
st_src0 |= PVR_ROGUE_PDSINST_ST_ST_SRC0_SLCMODE_WRITE_THROUGH; |
| 4388 |
} |
| 4389 |
|
| 4390 |
} else { |
| 4391 |
st_src0 |= control->cache_control_const; |
| 4392 |
} |
| 4393 |
|
| 4394 |
/* Write it to the constant. */ |
| 4395 |
pvr_pds_write_constant64(buffer, |
| 4396 |
constant, |
| 4397 |
(uint32_t)(st_src0), |
| 4398 |
(uint32_t)(st_src0 >> 32)); |
| 4399 |
|
| 4400 |
/* Adjust value for next ST instruction. */ |
| 4401 |
temp_index += per_inst_count; |
| 4402 |
count -= per_inst_count; |
| 4403 |
address += (((uint64_t)(per_inst_count)) << 2); |
| 4404 |
} |
| 4405 |
|
| 4406 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 4407 |
*buffer++ = pvr_pds_inst_encode_st(0, constant >> 1); |
| 4408 |
|
| 4409 |
if (data_fence) |
| 4410 |
*buffer++ = pvr_pds_inst_encode_wdf(0); |
| 4411 |
} |
| 4412 |
} |
| 4413 |
} |
| 4414 |
|
| 4415 |
(*total_code_size) += num_inst; |
| 4416 |
if (data_fence) |
| 4417 |
(*total_code_size) += num_inst; |
| 4418 |
|
| 4419 |
if (gen_mode != PDS_GENERATE_SIZES) |
| 4420 |
return buffer; |
| 4421 |
return NULL; |
| 4422 |
} |
| 4423 |
|
| 4424 |
/** |
| 4425 |
* Generate programs used to prepare stream out, i.e., clear stream out buffer |
| 4426 |
* overflow flags and update Persistent temps by a ld instruction. |
| 4427 |
* |
| 4428 |
* This must be used in PPP state update. |
| 4429 |
* |
| 4430 |
* \param program Pointer to the stream out program. |
| 4431 |
* \param buffer Pointer to the buffer for the program. |
| 4432 |
* \param store_mode If true then the data is stored to memory. If false then |
| 4433 |
* the data is loaded from memory. |
| 4434 |
* \param gen_mode Either code and data can be generated or sizes only updated. |
| 4435 |
* \param dev_info PVR device information structure. |
| 4436 |
* \returns Pointer to just beyond the buffer for the program. |
| 4437 |
*/ |
| 4438 |
uint32_t *pvr_pds_generate_stream_out_init_program( |
| 4439 |
struct pvr_pds_stream_out_init_program *restrict program, |
| 4440 |
uint32_t *restrict buffer, |
| 4441 |
bool store_mode, |
| 4442 |
enum pvr_pds_generate_mode gen_mode, |
| 4443 |
const struct pvr_device_info *dev_info) |
| 4444 |
{ |
| 4445 |
uint32_t total_data_size = 0; |
| 4446 |
uint32_t PTDst = PVR_ROGUE_PDSINST_REGS32TP_PTEMP32_LOWER; |
| 4447 |
|
| 4448 |
/* Start counting constants from 0. */ |
| 4449 |
uint32_t next_constant = PVR_PDS_CONSTANTS_BLOCK_BASE; |
| 4450 |
|
| 4451 |
uint32_t total_code_size = 1; |
| 4452 |
|
| 4453 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 4454 |
/* We only need to clear global stream out predicate, other predicates |
| 4455 |
* are not used during the stream out buffer overflow test. |
| 4456 |
*/ |
| 4457 |
*buffer++ = pvr_pds_inst_encode_stmc(0, 0x10); |
| 4458 |
} |
| 4459 |
|
| 4460 |
for (uint32_t index = 0; index < program->num_buffers; index++) { |
| 4461 |
if (program->dev_address_for_buffer_data[index] != 0) { |
| 4462 |
/* Generate load/store program to load/store persistent temps. */ |
| 4463 |
|
| 4464 |
/* NOTE: store_mode == true case should be handled by |
| 4465 |
* StreamOutTerminate. |
| 4466 |
*/ |
| 4467 |
buffer = pvr_pds_generate_single_ldst_instruction( |
| 4468 |
!store_mode, |
| 4469 |
NULL, |
| 4470 |
PTDst, |
| 4471 |
program->dev_address_for_buffer_data[index], |
| 4472 |
program->pds_buffer_data_size[index], |
| 4473 |
&next_constant, |
| 4474 |
&total_data_size, |
| 4475 |
&total_code_size, |
| 4476 |
buffer, |
| 4477 |
false, |
| 4478 |
gen_mode, |
| 4479 |
dev_info); |
| 4480 |
} |
| 4481 |
|
| 4482 |
PTDst += program->pds_buffer_data_size[index]; |
| 4483 |
} |
| 4484 |
|
| 4485 |
total_code_size += 2; |
| 4486 |
|
| 4487 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 4488 |
/* We need to fence the loading. */ |
| 4489 |
*buffer++ = pvr_pds_inst_encode_wdf(0); |
| 4490 |
*buffer++ = pvr_pds_inst_encode_halt(0); |
| 4491 |
} |
| 4492 |
|
| 4493 |
/* Save size information to program */ |
| 4494 |
program->stream_out_init_pds_data_size = |
| 4495 |
ALIGN_POT(total_data_size, 4); /* 128-bit boundary = 4 dwords; */ |
| 4496 |
/* PDS program code size. */ |
| 4497 |
program->stream_out_init_pds_code_size = total_code_size; |
| 4498 |
|
| 4499 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) |
| 4500 |
return buffer + program->stream_out_init_pds_data_size; |
| 4501 |
else if (gen_mode == PDS_GENERATE_CODE_SEGMENT) |
| 4502 |
return buffer; |
| 4503 |
|
| 4504 |
return NULL; |
| 4505 |
} |
| 4506 |
|
| 4507 |
/** |
| 4508 |
* Generate stream out terminate program for stream out. |
| 4509 |
* |
| 4510 |
* If pds_persistent_temp_size_to_store is 0, the final primitive written value |
| 4511 |
* will be stored. |
| 4512 |
* |
| 4513 |
* If pds_persistent_temp_size_to_store is non 0, the value of persistent temps |
| 4514 |
* will be stored into memory. |
| 4515 |
* |
| 4516 |
* The stream out terminate program is used to update the PPP state and the data |
| 4517 |
* and code section cannot be separate. |
| 4518 |
* |
| 4519 |
* \param program Pointer to the stream out program. |
| 4520 |
* \param buffer Pointer to the buffer for the program. |
| 4521 |
* \param gen_mode Either code and data can be generated or sizes only updated. |
| 4522 |
* \param dev_info PVR device info structure. |
| 4523 |
* \returns Pointer to just beyond the buffer for the program. |
| 4524 |
*/ |
| 4525 |
uint32_t *pvr_pds_generate_stream_out_terminate_program( |
| 4526 |
struct pvr_pds_stream_out_terminate_program *restrict program, |
| 4527 |
uint32_t *restrict buffer, |
| 4528 |
enum pvr_pds_generate_mode gen_mode, |
| 4529 |
const struct pvr_device_info *dev_info) |
| 4530 |
{ |
| 4531 |
uint32_t next_constant; |
| 4532 |
uint32_t total_data_size = 0, total_code_size = 0; |
| 4533 |
|
| 4534 |
/* Start counting constants from 0. */ |
| 4535 |
next_constant = PVR_PDS_CONSTANTS_BLOCK_BASE; |
| 4536 |
|
| 4537 |
/* Generate store program to store persistent temps. */ |
| 4538 |
buffer = pvr_pds_generate_single_ldst_instruction( |
| 4539 |
false, |
| 4540 |
NULL, |
| 4541 |
PVR_ROGUE_PDSINST_REGS32TP_PTEMP32_LOWER, |
| 4542 |
program->dev_address_for_storing_persistent_temp, |
| 4543 |
program->pds_persistent_temp_size_to_store, |
| 4544 |
&next_constant, |
| 4545 |
&total_data_size, |
| 4546 |
&total_code_size, |
| 4547 |
buffer, |
| 4548 |
false, |
| 4549 |
gen_mode, |
| 4550 |
dev_info); |
| 4551 |
|
| 4552 |
total_code_size += 2; |
| 4553 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 4554 |
*buffer++ = pvr_pds_inst_encode_wdf(0); |
| 4555 |
*buffer++ = pvr_pds_inst_encode_halt(0); |
| 4556 |
} |
| 4557 |
|
| 4558 |
/* Save size information to program. */ |
| 4559 |
program->stream_out_terminate_pds_data_size = |
| 4560 |
ALIGN_POT(total_data_size, 4); /* 128-bit boundary = 4 dwords; */ |
| 4561 |
/* PDS program code size. */ |
| 4562 |
program->stream_out_terminate_pds_code_size = total_code_size; |
| 4563 |
|
| 4564 |
if (gen_mode == PDS_GENERATE_DATA_SEGMENT) |
| 4565 |
return buffer + program->stream_out_terminate_pds_data_size; |
| 4566 |
else if (gen_mode == PDS_GENERATE_CODE_SEGMENT) |
| 4567 |
return buffer; |
| 4568 |
|
| 4569 |
return NULL; |
| 4570 |
} |
| 4571 |
|
| 4572 |
uint32_t *pvr_pds_generate_view_index_init_program( |
| 4573 |
struct pvr_pds_view_index_init_program *restrict program, |
| 4574 |
uint32_t *restrict buffer, |
| 4575 |
enum pvr_pds_generate_mode gen_mode) |
| 4576 |
{ |
| 4577 |
uint32_t next_temp = PVR_PDS_TEMPS_BLOCK_BASE; |
| 4578 |
uint32_t temps_used = 0; |
| 4579 |
uint32_t data_size = 0; |
| 4580 |
uint32_t code_size = 0; |
| 4581 |
|
| 4582 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT || |
| 4583 |
gen_mode == PDS_GENERATE_SIZES) { |
| 4584 |
const bool encode = (gen_mode == PDS_GENERATE_CODE_SEGMENT); |
| 4585 |
#define APPEND(X) \ |
| 4586 |
if (encode) { \ |
| 4587 |
*buffer = X; \ |
| 4588 |
buffer++; \ |
| 4589 |
} else { \ |
| 4590 |
code_size += sizeof(uint32_t); \ |
| 4591 |
} |
| 4592 |
|
| 4593 |
uint32_t view_index_temp = pvr_pds_get_temps(&next_temp, 1, &temps_used); |
| 4594 |
uint32_t zero_temp = pvr_pds_get_temps(&next_temp, 1, &temps_used); |
| 4595 |
|
| 4596 |
/* Load the view index into a view_index_temp. */ |
| 4597 |
APPEND( |
| 4598 |
pvr_pds_inst_encode_limm(0, view_index_temp, program->view_index, 0)); |
| 4599 |
|
| 4600 |
/* Load the zero into a zero_temp. */ |
| 4601 |
APPEND(pvr_pds_inst_encode_limm(0, zero_temp, 0, 0)); |
| 4602 |
|
| 4603 |
/* Copy the temp into ptemp. */ |
| 4604 |
APPEND(pvr_pds_inst_encode_add32( |
| 4605 |
0, |
| 4606 |
0, |
| 4607 |
0, |
| 4608 |
view_index_temp, |
| 4609 |
zero_temp, |
| 4610 |
PVR_ROGUE_PDSINST_REGS32TP_PTEMP32_LOWER + PVR_PTEMP_VIEW_INDEX)); |
| 4611 |
|
| 4612 |
APPEND(pvr_pds_inst_encode_halt(0)); |
| 4613 |
#undef APPEND |
| 4614 |
|
| 4615 |
program->temps_used = temps_used; |
| 4616 |
} |
| 4617 |
|
| 4618 |
if (gen_mode == PDS_GENERATE_SIZES) { |
| 4619 |
program->code_size = code_size; |
| 4620 |
program->data_size = data_size; |
| 4621 |
} |
| 4622 |
|
| 4623 |
return buffer; |
| 4624 |
} |
| 4625 |
|
| 4626 |
/* DrawArrays works in several steps: |
| 4627 |
* |
| 4628 |
* 1) load data from draw_indirect buffer |
| 4629 |
* 2) tweak data to match hardware formats |
| 4630 |
* 3) write data to indexblock |
| 4631 |
* 4) signal the VDM to continue |
| 4632 |
* |
| 4633 |
* This is complicated by HW limitations on alignment, as well as a HWBRN. |
| 4634 |
* |
| 4635 |
* 1) Load data. |
| 4636 |
* Loads _must_ be 128-bit aligned. Because there is no such limitation in the |
| 4637 |
* spec we must deal with this by choosing an appropriate earlier address and |
| 4638 |
* loading enough dwords that we load the entirety of the buffer. |
| 4639 |
* |
| 4640 |
* if addr & 0xf: |
| 4641 |
* load [addr & ~0xf] 6 dwords -> tmp[0, 1, 2, 3, 4, 5] |
| 4642 |
* data = tmp[0 + (uiAddr & 0xf) >> 2]... |
| 4643 |
* else |
| 4644 |
* load [addr] 4 dwords -> tmp[0, 1, 2, 3] |
| 4645 |
* data = tmp[0]... |
| 4646 |
* |
| 4647 |
* |
| 4648 |
* 2) Tweak data. |
| 4649 |
* primCount in the spec does not match the encoding of INDEX_INSTANCE_COUNT in |
| 4650 |
* the VDM control stream. We must subtract 1 from the loaded primCount. |
| 4651 |
* |
| 4652 |
* However, there is a HWBRN that disallows the ADD32 instruction from sourcing |
| 4653 |
* a tmp that is non-64-bit-aligned. To work around this, we must move primCount |
| 4654 |
* into another tmp that has the correct alignment. Note: this is only required |
| 4655 |
* when data = tmp[even], as primCount is data+1: |
| 4656 |
* |
| 4657 |
* if data = tmp[even]: |
| 4658 |
* primCount = data + 1 = tmp[odd] -- not 64-bit aligned! |
| 4659 |
* else: |
| 4660 |
* primCount = data + 1 = tmp[even] -- already aligned, don't need workaround. |
| 4661 |
* |
| 4662 |
* This boils down to: |
| 4663 |
* |
| 4664 |
* primCount = data[1] |
| 4665 |
* primCountSrc = data[1] |
| 4666 |
* if brn_present && (data is even): |
| 4667 |
* mov scratch, primCount |
| 4668 |
* primCountSrc = scratch |
| 4669 |
* endif |
| 4670 |
* sub primCount, primCountSrc, 1 |
| 4671 |
* |
| 4672 |
* 3) Store Data. |
| 4673 |
* Write the now-tweaked data over the top of the indexblock. |
| 4674 |
* To ensure the write completes before the VDM re-reads the data, we must cause |
| 4675 |
* a data hazard by doing a dummy (dummy meaning we don't care about the |
| 4676 |
* returned data) load from the same addresses. Again, because the ld must |
| 4677 |
* always be 128-bit aligned (note: the ST is dword-aligned), we must ensure the |
| 4678 |
* index block is 128-bit aligned. This is the client driver's responsibility. |
| 4679 |
* |
| 4680 |
* st data[0, 1, 2] -> (idxblock + 4) |
| 4681 |
* load [idxblock] 4 dwords |
| 4682 |
* |
| 4683 |
* 4) Signal the VDM |
| 4684 |
* This is simply a DOUTV with a src1 of 0, indicating the VDM should continue |
| 4685 |
* where it is currently fenced on a dummy idxblock that has been inserted by |
| 4686 |
* the driver. |
| 4687 |
*/ |
| 4688 |
|
| 4689 |
#include "pvr_draw_indirect_arrays0.h" |
| 4690 |
#include "pvr_draw_indirect_arrays1.h" |
| 4691 |
#include "pvr_draw_indirect_arrays2.h" |
| 4692 |
#include "pvr_draw_indirect_arrays3.h" |
| 4693 |
|
| 4694 |
#include "pvr_draw_indirect_arrays_base_instance0.h" |
| 4695 |
#include "pvr_draw_indirect_arrays_base_instance1.h" |
| 4696 |
#include "pvr_draw_indirect_arrays_base_instance2.h" |
| 4697 |
#include "pvr_draw_indirect_arrays_base_instance3.h" |
| 4698 |
|
| 4699 |
#include "pvr_draw_indirect_arrays_base_instance_drawid0.h" |
| 4700 |
#include "pvr_draw_indirect_arrays_base_instance_drawid1.h" |
| 4701 |
#include "pvr_draw_indirect_arrays_base_instance_drawid2.h" |
| 4702 |
#include "pvr_draw_indirect_arrays_base_instance_drawid3.h" |
| 4703 |
|
| 4704 |
#define ENABLE_SLC_MCU_CACHE_CONTROLS(device) \ |
| 4705 |
((device)->features.has_slc_mcu_cache_controls \ |
| 4706 |
? PVR_ROGUE_PDSINST_LD_LD_SRC0_SLCMODE_CACHED \ |
| 4707 |
: PVR_ROGUE_PDSINST_LD_LD_SRC0_SLCMODE_BYPASS) |
| 4708 |
|
| 4709 |
void pvr_pds_generate_draw_arrays_indirect( |
| 4710 |
struct pvr_pds_drawindirect_program *restrict program, |
| 4711 |
uint32_t *restrict buffer, |
| 4712 |
enum pvr_pds_generate_mode gen_mode, |
| 4713 |
const struct pvr_device_info *dev_info) |
| 4714 |
{ |
| 4715 |
if ((gen_mode == PDS_GENERATE_CODE_SEGMENT) || |
| 4716 |
(gen_mode == PDS_GENERATE_SIZES)) { |
| 4717 |
const struct pvr_psc_program_output *psc_program = NULL; |
| 4718 |
switch ((program->arg_buffer >> 2) % 4) { |
| 4719 |
case 0: |
| 4720 |
if (program->support_base_instance) { |
| 4721 |
if (program->increment_draw_id) { |
| 4722 |
psc_program = |
| 4723 |
&pvr_draw_indirect_arrays_base_instance_drawid0_program; |
| 4724 |
} else { |
| 4725 |
psc_program = &pvr_draw_indirect_arrays_base_instance0_program; |
| 4726 |
} |
| 4727 |
} else { |
| 4728 |
psc_program = &pvr_draw_indirect_arrays0_program; |
| 4729 |
} |
| 4730 |
break; |
| 4731 |
case 1: |
| 4732 |
if (program->support_base_instance) { |
| 4733 |
if (program->increment_draw_id) { |
| 4734 |
psc_program = |
| 4735 |
&pvr_draw_indirect_arrays_base_instance_drawid1_program; |
| 4736 |
} else { |
| 4737 |
psc_program = &pvr_draw_indirect_arrays_base_instance1_program; |
| 4738 |
} |
| 4739 |
} else { |
| 4740 |
psc_program = &pvr_draw_indirect_arrays1_program; |
| 4741 |
} |
| 4742 |
break; |
| 4743 |
case 2: |
| 4744 |
if (program->support_base_instance) { |
| 4745 |
if (program->increment_draw_id) { |
| 4746 |
psc_program = |
| 4747 |
&pvr_draw_indirect_arrays_base_instance_drawid2_program; |
| 4748 |
} else { |
| 4749 |
psc_program = &pvr_draw_indirect_arrays_base_instance2_program; |
| 4750 |
} |
| 4751 |
} else { |
| 4752 |
psc_program = &pvr_draw_indirect_arrays2_program; |
| 4753 |
} |
| 4754 |
break; |
| 4755 |
case 3: |
| 4756 |
if (program->support_base_instance) { |
| 4757 |
if (program->increment_draw_id) { |
| 4758 |
psc_program = |
| 4759 |
&pvr_draw_indirect_arrays_base_instance_drawid3_program; |
| 4760 |
} else { |
| 4761 |
psc_program = &pvr_draw_indirect_arrays_base_instance3_program; |
| 4762 |
} |
| 4763 |
} else { |
| 4764 |
psc_program = &pvr_draw_indirect_arrays3_program; |
| 4765 |
} |
| 4766 |
break; |
| 4767 |
} |
| 4768 |
|
| 4769 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 4770 |
memcpy(buffer, |
| 4771 |
psc_program->code, |
| 4772 |
psc_program->code_size * sizeof(uint32_t)); |
| 4773 |
#if defined(DUMP_PDS) |
| 4774 |
for (uint32_t i = 0; i < psc_program->code_size; i++) |
| 4775 |
PVR_PDS_PRINT_INST(buffer[i]); |
| 4776 |
#endif |
| 4777 |
} |
| 4778 |
|
| 4779 |
program->program = *psc_program; |
| 4780 |
} else { |
| 4781 |
switch ((program->arg_buffer >> 2) % 4) { |
| 4782 |
case 0: |
| 4783 |
if (program->support_base_instance) { |
| 4784 |
if (program->increment_draw_id) { |
| 4785 |
pvr_write_draw_indirect_arrays_base_instance_drawid0_di_data( |
| 4786 |
buffer, |
| 4787 |
program->arg_buffer & ~0xfull, |
| 4788 |
dev_info); |
| 4789 |
pvr_write_draw_indirect_arrays_base_instance_drawid0_write_vdm( |
| 4790 |
buffer, |
| 4791 |
program->index_list_addr_buffer + 4); |
| 4792 |
pvr_write_draw_indirect_arrays_base_instance_drawid0_flush_vdm( |
| 4793 |
buffer, |
| 4794 |
program->index_list_addr_buffer); |
| 4795 |
pvr_write_draw_indirect_arrays_base_instance_drawid0_num_views( |
| 4796 |
buffer, |
| 4797 |
program->num_views); |
| 4798 |
pvr_write_draw_indirect_arrays_base_instance_drawid0_immediates( |
| 4799 |
buffer); |
| 4800 |
} else { |
| 4801 |
pvr_write_draw_indirect_arrays_base_instance0_di_data( |
| 4802 |
buffer, |
| 4803 |
program->arg_buffer & ~0xfull, |
| 4804 |
dev_info); |
| 4805 |
pvr_write_draw_indirect_arrays_base_instance0_write_vdm( |
| 4806 |
buffer, |
| 4807 |
program->index_list_addr_buffer + 4); |
| 4808 |
pvr_write_draw_indirect_arrays_base_instance0_flush_vdm( |
| 4809 |
buffer, |
| 4810 |
program->index_list_addr_buffer); |
| 4811 |
pvr_write_draw_indirect_arrays_base_instance0_num_views( |
| 4812 |
buffer, |
| 4813 |
program->num_views); |
| 4814 |
pvr_write_draw_indirect_arrays_base_instance0_immediates(buffer); |
| 4815 |
} |
| 4816 |
} else { |
| 4817 |
pvr_write_draw_indirect_arrays0_di_data(buffer, |
| 4818 |
program->arg_buffer & |
| 4819 |
~0xfull, |
| 4820 |
dev_info); |
| 4821 |
pvr_write_draw_indirect_arrays0_write_vdm( |
| 4822 |
buffer, |
| 4823 |
program->index_list_addr_buffer + 4); |
| 4824 |
pvr_write_draw_indirect_arrays0_flush_vdm( |
| 4825 |
buffer, |
| 4826 |
program->index_list_addr_buffer); |
| 4827 |
pvr_write_draw_indirect_arrays0_num_views(buffer, |
| 4828 |
program->num_views); |
| 4829 |
pvr_write_draw_indirect_arrays0_immediates(buffer); |
| 4830 |
} |
| 4831 |
break; |
| 4832 |
case 1: |
| 4833 |
if (program->support_base_instance) { |
| 4834 |
if (program->increment_draw_id) { |
| 4835 |
pvr_write_draw_indirect_arrays_base_instance_drawid1_di_data( |
| 4836 |
buffer, |
| 4837 |
program->arg_buffer & ~0xfull, |
| 4838 |
dev_info); |
| 4839 |
pvr_write_draw_indirect_arrays_base_instance_drawid1_write_vdm( |
| 4840 |
buffer, |
| 4841 |
program->index_list_addr_buffer + 4); |
| 4842 |
pvr_write_draw_indirect_arrays_base_instance_drawid1_flush_vdm( |
| 4843 |
buffer, |
| 4844 |
program->index_list_addr_buffer); |
| 4845 |
pvr_write_draw_indirect_arrays_base_instance_drawid1_num_views( |
| 4846 |
buffer, |
| 4847 |
program->num_views); |
| 4848 |
pvr_write_draw_indirect_arrays_base_instance_drawid1_immediates( |
| 4849 |
buffer); |
| 4850 |
} else { |
| 4851 |
pvr_write_draw_indirect_arrays_base_instance1_di_data( |
| 4852 |
buffer, |
| 4853 |
program->arg_buffer & ~0xfull, |
| 4854 |
dev_info); |
| 4855 |
pvr_write_draw_indirect_arrays_base_instance1_write_vdm( |
| 4856 |
buffer, |
| 4857 |
program->index_list_addr_buffer + 4); |
| 4858 |
pvr_write_draw_indirect_arrays_base_instance1_flush_vdm( |
| 4859 |
buffer, |
| 4860 |
program->index_list_addr_buffer); |
| 4861 |
pvr_write_draw_indirect_arrays_base_instance1_num_views( |
| 4862 |
buffer, |
| 4863 |
program->num_views); |
| 4864 |
pvr_write_draw_indirect_arrays_base_instance1_immediates(buffer); |
| 4865 |
} |
| 4866 |
} else { |
| 4867 |
pvr_write_draw_indirect_arrays1_di_data(buffer, |
| 4868 |
program->arg_buffer & |
| 4869 |
~0xfull, |
| 4870 |
dev_info); |
| 4871 |
pvr_write_draw_indirect_arrays1_write_vdm( |
| 4872 |
buffer, |
| 4873 |
program->index_list_addr_buffer + 4); |
| 4874 |
pvr_write_draw_indirect_arrays1_flush_vdm( |
| 4875 |
buffer, |
| 4876 |
program->index_list_addr_buffer); |
| 4877 |
pvr_write_draw_indirect_arrays1_num_views(buffer, |
| 4878 |
program->num_views); |
| 4879 |
pvr_write_draw_indirect_arrays1_immediates(buffer); |
| 4880 |
} |
| 4881 |
break; |
| 4882 |
case 2: |
| 4883 |
if (program->support_base_instance) { |
| 4884 |
if (program->increment_draw_id) { |
| 4885 |
pvr_write_draw_indirect_arrays_base_instance_drawid2_di_data( |
| 4886 |
buffer, |
| 4887 |
program->arg_buffer & ~0xfull, |
| 4888 |
dev_info); |
| 4889 |
pvr_write_draw_indirect_arrays_base_instance_drawid2_write_vdm( |
| 4890 |
buffer, |
| 4891 |
program->index_list_addr_buffer + 4); |
| 4892 |
pvr_write_draw_indirect_arrays_base_instance_drawid2_flush_vdm( |
| 4893 |
buffer, |
| 4894 |
program->index_list_addr_buffer); |
| 4895 |
pvr_write_draw_indirect_arrays_base_instance_drawid2_num_views( |
| 4896 |
buffer, |
| 4897 |
program->num_views); |
| 4898 |
pvr_write_draw_indirect_arrays_base_instance_drawid2_immediates( |
| 4899 |
buffer); |
| 4900 |
} else { |
| 4901 |
pvr_write_draw_indirect_arrays_base_instance2_di_data( |
| 4902 |
buffer, |
| 4903 |
program->arg_buffer & ~0xfull, |
| 4904 |
dev_info); |
| 4905 |
pvr_write_draw_indirect_arrays_base_instance2_write_vdm( |
| 4906 |
buffer, |
| 4907 |
program->index_list_addr_buffer + 4); |
| 4908 |
pvr_write_draw_indirect_arrays_base_instance2_flush_vdm( |
| 4909 |
buffer, |
| 4910 |
program->index_list_addr_buffer); |
| 4911 |
pvr_write_draw_indirect_arrays_base_instance2_num_views( |
| 4912 |
buffer, |
| 4913 |
program->num_views); |
| 4914 |
pvr_write_draw_indirect_arrays_base_instance2_immediates(buffer); |
| 4915 |
} |
| 4916 |
} else { |
| 4917 |
pvr_write_draw_indirect_arrays2_di_data(buffer, |
| 4918 |
program->arg_buffer & |
| 4919 |
~0xfull, |
| 4920 |
dev_info); |
| 4921 |
pvr_write_draw_indirect_arrays2_write_vdm( |
| 4922 |
buffer, |
| 4923 |
program->index_list_addr_buffer + 4); |
| 4924 |
pvr_write_draw_indirect_arrays2_flush_vdm( |
| 4925 |
buffer, |
| 4926 |
program->index_list_addr_buffer); |
| 4927 |
pvr_write_draw_indirect_arrays2_num_views(buffer, |
| 4928 |
program->num_views); |
| 4929 |
pvr_write_draw_indirect_arrays2_immediates(buffer); |
| 4930 |
} |
| 4931 |
break; |
| 4932 |
case 3: |
| 4933 |
if (program->support_base_instance) { |
| 4934 |
if (program->increment_draw_id) { |
| 4935 |
pvr_write_draw_indirect_arrays_base_instance_drawid3_di_data( |
| 4936 |
buffer, |
| 4937 |
program->arg_buffer & ~0xfull, |
| 4938 |
dev_info); |
| 4939 |
pvr_write_draw_indirect_arrays_base_instance_drawid3_write_vdm( |
| 4940 |
buffer, |
| 4941 |
program->index_list_addr_buffer + 4); |
| 4942 |
pvr_write_draw_indirect_arrays_base_instance_drawid3_flush_vdm( |
| 4943 |
buffer, |
| 4944 |
program->index_list_addr_buffer); |
| 4945 |
pvr_write_draw_indirect_arrays_base_instance_drawid3_num_views( |
| 4946 |
buffer, |
| 4947 |
program->num_views); |
| 4948 |
pvr_write_draw_indirect_arrays_base_instance_drawid3_immediates( |
| 4949 |
buffer); |
| 4950 |
} else { |
| 4951 |
pvr_write_draw_indirect_arrays_base_instance3_di_data( |
| 4952 |
buffer, |
| 4953 |
program->arg_buffer & ~0xfull, |
| 4954 |
dev_info); |
| 4955 |
pvr_write_draw_indirect_arrays_base_instance3_write_vdm( |
| 4956 |
buffer, |
| 4957 |
program->index_list_addr_buffer + 4); |
| 4958 |
pvr_write_draw_indirect_arrays_base_instance3_flush_vdm( |
| 4959 |
buffer, |
| 4960 |
program->index_list_addr_buffer); |
| 4961 |
pvr_write_draw_indirect_arrays_base_instance3_num_views( |
| 4962 |
buffer, |
| 4963 |
program->num_views); |
| 4964 |
pvr_write_draw_indirect_arrays_base_instance3_immediates(buffer); |
| 4965 |
} |
| 4966 |
} else { |
| 4967 |
pvr_write_draw_indirect_arrays3_di_data(buffer, |
| 4968 |
program->arg_buffer & |
| 4969 |
~0xfull, |
| 4970 |
dev_info); |
| 4971 |
pvr_write_draw_indirect_arrays3_write_vdm( |
| 4972 |
buffer, |
| 4973 |
program->index_list_addr_buffer + 4); |
| 4974 |
pvr_write_draw_indirect_arrays3_flush_vdm( |
| 4975 |
buffer, |
| 4976 |
program->index_list_addr_buffer); |
| 4977 |
pvr_write_draw_indirect_arrays3_num_views(buffer, |
| 4978 |
program->num_views); |
| 4979 |
pvr_write_draw_indirect_arrays3_immediates(buffer); |
| 4980 |
} |
| 4981 |
break; |
| 4982 |
} |
| 4983 |
} |
| 4984 |
} |
| 4985 |
|
| 4986 |
#include "pvr_draw_indirect_elements0.h" |
| 4987 |
#include "pvr_draw_indirect_elements1.h" |
| 4988 |
#include "pvr_draw_indirect_elements2.h" |
| 4989 |
#include "pvr_draw_indirect_elements3.h" |
| 4990 |
#include "pvr_draw_indirect_elements_base_instance0.h" |
| 4991 |
#include "pvr_draw_indirect_elements_base_instance1.h" |
| 4992 |
#include "pvr_draw_indirect_elements_base_instance2.h" |
| 4993 |
#include "pvr_draw_indirect_elements_base_instance3.h" |
| 4994 |
#include "pvr_draw_indirect_elements_base_instance_drawid0.h" |
| 4995 |
#include "pvr_draw_indirect_elements_base_instance_drawid1.h" |
| 4996 |
#include "pvr_draw_indirect_elements_base_instance_drawid2.h" |
| 4997 |
#include "pvr_draw_indirect_elements_base_instance_drawid3.h" |
| 4998 |
|
| 4999 |
void pvr_pds_generate_draw_elements_indirect( |
| 5000 |
struct pvr_pds_drawindirect_program *restrict program, |
| 5001 |
uint32_t *restrict buffer, |
| 5002 |
enum pvr_pds_generate_mode gen_mode, |
| 5003 |
const struct pvr_device_info *dev_info) |
| 5004 |
{ |
| 5005 |
if ((gen_mode == PDS_GENERATE_CODE_SEGMENT) || |
| 5006 |
(gen_mode == PDS_GENERATE_SIZES)) { |
| 5007 |
const struct pvr_psc_program_output *psc_program = NULL; |
| 5008 |
switch ((program->arg_buffer >> 2) % 4) { |
| 5009 |
case 0: |
| 5010 |
if (program->support_base_instance) { |
| 5011 |
if (program->increment_draw_id) { |
| 5012 |
psc_program = |
| 5013 |
&pvr_draw_indirect_elements_base_instance_drawid0_program; |
| 5014 |
} else { |
| 5015 |
psc_program = &pvr_draw_indirect_elements_base_instance0_program; |
| 5016 |
} |
| 5017 |
} else { |
| 5018 |
psc_program = &pvr_draw_indirect_elements0_program; |
| 5019 |
} |
| 5020 |
break; |
| 5021 |
case 1: |
| 5022 |
if (program->support_base_instance) { |
| 5023 |
if (program->increment_draw_id) { |
| 5024 |
psc_program = |
| 5025 |
&pvr_draw_indirect_elements_base_instance_drawid1_program; |
| 5026 |
} else { |
| 5027 |
psc_program = &pvr_draw_indirect_elements_base_instance1_program; |
| 5028 |
} |
| 5029 |
} else { |
| 5030 |
psc_program = &pvr_draw_indirect_elements1_program; |
| 5031 |
} |
| 5032 |
break; |
| 5033 |
case 2: |
| 5034 |
if (program->support_base_instance) { |
| 5035 |
if (program->increment_draw_id) { |
| 5036 |
psc_program = |
| 5037 |
&pvr_draw_indirect_elements_base_instance_drawid2_program; |
| 5038 |
} else { |
| 5039 |
psc_program = &pvr_draw_indirect_elements_base_instance2_program; |
| 5040 |
} |
| 5041 |
} else { |
| 5042 |
psc_program = &pvr_draw_indirect_elements2_program; |
| 5043 |
} |
| 5044 |
break; |
| 5045 |
case 3: |
| 5046 |
if (program->support_base_instance) { |
| 5047 |
if (program->increment_draw_id) { |
| 5048 |
psc_program = |
| 5049 |
&pvr_draw_indirect_elements_base_instance_drawid3_program; |
| 5050 |
} else { |
| 5051 |
psc_program = &pvr_draw_indirect_elements_base_instance3_program; |
| 5052 |
} |
| 5053 |
} else { |
| 5054 |
psc_program = &pvr_draw_indirect_elements3_program; |
| 5055 |
} |
| 5056 |
break; |
| 5057 |
} |
| 5058 |
|
| 5059 |
if (gen_mode == PDS_GENERATE_CODE_SEGMENT) { |
| 5060 |
memcpy(buffer, |
| 5061 |
psc_program->code, |
| 5062 |
psc_program->code_size * sizeof(uint32_t)); |
| 5063 |
|
| 5064 |
#if defined(DUMP_PDS) |
| 5065 |
for (uint32_t i = 0; i < psc_program->code_size; i++) |
| 5066 |
PVR_PDS_PRINT_INST(buffer[i]); |
| 5067 |
#endif |
| 5068 |
} |
| 5069 |
|
| 5070 |
program->program = *psc_program; |
| 5071 |
} else { |
| 5072 |
switch ((program->arg_buffer >> 2) % 4) { |
| 5073 |
case 0: |
| 5074 |
if (program->support_base_instance) { |
| 5075 |
if (program->increment_draw_id) { |
| 5076 |
pvr_write_draw_indirect_elements_base_instance_drawid0_di_data( |
| 5077 |
buffer, |
| 5078 |
program->arg_buffer & ~0xfull, |
| 5079 |
dev_info); |
| 5080 |
pvr_write_draw_indirect_elements_base_instance_drawid0_write_vdm( |
| 5081 |
buffer, |
| 5082 |
program->index_list_addr_buffer); |
| 5083 |
pvr_write_draw_indirect_elements_base_instance_drawid0_flush_vdm( |
| 5084 |
buffer, |
| 5085 |
program->index_list_addr_buffer); |
| 5086 |
pvr_write_draw_indirect_elements_base_instance_drawid0_num_views( |
| 5087 |
buffer, |
| 5088 |
program->num_views); |
| 5089 |
pvr_write_draw_indirect_elements_base_instance_drawid0_idx_stride( |
| 5090 |
buffer, |
| 5091 |
program->index_stride); |
| 5092 |
pvr_write_draw_indirect_elements_base_instance_drawid0_idx_base( |
| 5093 |
buffer, |
| 5094 |
program->index_buffer); |
| 5095 |
pvr_write_draw_indirect_elements_base_instance_drawid0_idx_header( |
| 5096 |
buffer, |
| 5097 |
program->index_block_header); |
| 5098 |
pvr_write_draw_indirect_elements_base_instance_drawid0_immediates( |
| 5099 |
buffer); |
| 5100 |
} else { |
| 5101 |
pvr_write_draw_indirect_elements_base_instance0_di_data( |
| 5102 |
buffer, |
| 5103 |
program->arg_buffer & ~0xfull, |
| 5104 |
dev_info); |
| 5105 |
pvr_write_draw_indirect_elements_base_instance0_write_vdm( |
| 5106 |
buffer, |
| 5107 |
program->index_list_addr_buffer); |
| 5108 |
pvr_write_draw_indirect_elements_base_instance0_flush_vdm( |
| 5109 |
buffer, |
| 5110 |
program->index_list_addr_buffer); |
| 5111 |
pvr_write_draw_indirect_elements_base_instance0_num_views( |
| 5112 |
buffer, |
| 5113 |
program->num_views); |
| 5114 |
pvr_write_draw_indirect_elements_base_instance0_idx_stride( |
| 5115 |
buffer, |
| 5116 |
program->index_stride); |
| 5117 |
pvr_write_draw_indirect_elements_base_instance0_idx_base( |
| 5118 |
buffer, |
| 5119 |
program->index_buffer); |
| 5120 |
pvr_write_draw_indirect_elements_base_instance0_idx_header( |
| 5121 |
buffer, |
| 5122 |
program->index_block_header); |
| 5123 |
pvr_write_draw_indirect_elements_base_instance0_immediates( |
| 5124 |
buffer); |
| 5125 |
} |
| 5126 |
} else { |
| 5127 |
pvr_write_draw_indirect_elements0_di_data(buffer, |
| 5128 |
program->arg_buffer & |
| 5129 |
~0xfull, |
| 5130 |
dev_info); |
| 5131 |
pvr_write_draw_indirect_elements0_write_vdm( |
| 5132 |
buffer, |
| 5133 |
program->index_list_addr_buffer); |
| 5134 |
pvr_write_draw_indirect_elements0_flush_vdm( |
| 5135 |
buffer, |
| 5136 |
program->index_list_addr_buffer); |
| 5137 |
pvr_write_draw_indirect_elements0_num_views(buffer, |
| 5138 |
program->num_views); |
| 5139 |
pvr_write_draw_indirect_elements0_idx_stride(buffer, |
| 5140 |
program->index_stride); |
| 5141 |
pvr_write_draw_indirect_elements0_idx_base(buffer, |
| 5142 |
program->index_buffer); |
| 5143 |
pvr_write_draw_indirect_elements0_idx_header( |
| 5144 |
buffer, |
| 5145 |
program->index_block_header); |
| 5146 |
pvr_write_draw_indirect_elements0_immediates(buffer); |
| 5147 |
} |
| 5148 |
break; |
| 5149 |
case 1: |
| 5150 |
if (program->support_base_instance) { |
| 5151 |
if (program->increment_draw_id) { |
| 5152 |
pvr_write_draw_indirect_elements_base_instance_drawid1_di_data( |
| 5153 |
buffer, |
| 5154 |
program->arg_buffer & ~0xfull, |
| 5155 |
dev_info); |
| 5156 |
pvr_write_draw_indirect_elements_base_instance_drawid1_write_vdm( |
| 5157 |
buffer, |
| 5158 |
program->index_list_addr_buffer); |
| 5159 |
pvr_write_draw_indirect_elements_base_instance_drawid1_flush_vdm( |
| 5160 |
buffer, |
| 5161 |
program->index_list_addr_buffer); |
| 5162 |
pvr_write_draw_indirect_elements_base_instance_drawid1_num_views( |
| 5163 |
buffer, |
| 5164 |
program->num_views); |
| 5165 |
pvr_write_draw_indirect_elements_base_instance_drawid1_idx_stride( |
| 5166 |
buffer, |
| 5167 |
program->index_stride); |
| 5168 |
pvr_write_draw_indirect_elements_base_instance_drawid1_idx_base( |
| 5169 |
buffer, |
| 5170 |
program->index_buffer); |
| 5171 |
pvr_write_draw_indirect_elements_base_instance_drawid1_idx_header( |
| 5172 |
buffer, |
| 5173 |
program->index_block_header); |
| 5174 |
pvr_write_draw_indirect_elements_base_instance_drawid1_immediates( |
| 5175 |
buffer); |
| 5176 |
} else { |
| 5177 |
pvr_write_draw_indirect_elements_base_instance1_di_data( |
| 5178 |
buffer, |
| 5179 |
program->arg_buffer & ~0xfull, |
| 5180 |
dev_info); |
| 5181 |
pvr_write_draw_indirect_elements_base_instance1_write_vdm( |
| 5182 |
buffer, |
| 5183 |
program->index_list_addr_buffer); |
| 5184 |
pvr_write_draw_indirect_elements_base_instance1_flush_vdm( |
| 5185 |
buffer, |
| 5186 |
program->index_list_addr_buffer); |
| 5187 |
pvr_write_draw_indirect_elements_base_instance1_num_views( |
| 5188 |
buffer, |
| 5189 |
program->num_views); |
| 5190 |
pvr_write_draw_indirect_elements_base_instance1_idx_stride( |
| 5191 |
buffer, |
| 5192 |
program->index_stride); |
| 5193 |
pvr_write_draw_indirect_elements_base_instance1_idx_base( |
| 5194 |
buffer, |
| 5195 |
program->index_buffer); |
| 5196 |
pvr_write_draw_indirect_elements_base_instance1_idx_header( |
| 5197 |
buffer, |
| 5198 |
program->index_block_header); |
| 5199 |
pvr_write_draw_indirect_elements_base_instance1_immediates( |
| 5200 |
buffer); |
| 5201 |
} |
| 5202 |
} else { |
| 5203 |
pvr_write_draw_indirect_elements1_di_data(buffer, |
| 5204 |
program->arg_buffer & |
| 5205 |
~0xfull, |
| 5206 |
dev_info); |
| 5207 |
pvr_write_draw_indirect_elements1_write_vdm( |
| 5208 |
buffer, |
| 5209 |
program->index_list_addr_buffer); |
| 5210 |
pvr_write_draw_indirect_elements1_flush_vdm( |
| 5211 |
buffer, |
| 5212 |
program->index_list_addr_buffer); |
| 5213 |
pvr_write_draw_indirect_elements1_num_views(buffer, |
| 5214 |
program->num_views); |
| 5215 |
pvr_write_draw_indirect_elements1_idx_stride(buffer, |
| 5216 |
program->index_stride); |
| 5217 |
pvr_write_draw_indirect_elements1_idx_base(buffer, |
| 5218 |
program->index_buffer); |
| 5219 |
pvr_write_draw_indirect_elements1_idx_header( |
| 5220 |
buffer, |
| 5221 |
program->index_block_header); |
| 5222 |
pvr_write_draw_indirect_elements1_immediates(buffer); |
| 5223 |
} |
| 5224 |
break; |
| 5225 |
case 2: |
| 5226 |
if (program->support_base_instance) { |
| 5227 |
if (program->increment_draw_id) { |
| 5228 |
pvr_write_draw_indirect_elements_base_instance_drawid2_di_data( |
| 5229 |
buffer, |
| 5230 |
program->arg_buffer & ~0xfull, |
| 5231 |
dev_info); |
| 5232 |
pvr_write_draw_indirect_elements_base_instance_drawid2_write_vdm( |
| 5233 |
buffer, |
| 5234 |
program->index_list_addr_buffer); |
| 5235 |
pvr_write_draw_indirect_elements_base_instance_drawid2_flush_vdm( |
| 5236 |
buffer, |
| 5237 |
program->index_list_addr_buffer); |
| 5238 |
pvr_write_draw_indirect_elements_base_instance_drawid2_num_views( |
| 5239 |
buffer, |
| 5240 |
program->num_views); |
| 5241 |
pvr_write_draw_indirect_elements_base_instance_drawid2_idx_stride( |
| 5242 |
buffer, |
| 5243 |
program->index_stride); |
| 5244 |
pvr_write_draw_indirect_elements_base_instance_drawid2_idx_base( |
| 5245 |
buffer, |
| 5246 |
program->index_buffer); |
| 5247 |
pvr_write_draw_indirect_elements_base_instance_drawid2_idx_header( |
| 5248 |
buffer, |
| 5249 |
program->index_block_header); |
| 5250 |
pvr_write_draw_indirect_elements_base_instance_drawid2_immediates( |
| 5251 |
buffer); |
| 5252 |
} else { |
| 5253 |
pvr_write_draw_indirect_elements_base_instance2_di_data( |
| 5254 |
buffer, |
| 5255 |
program->arg_buffer & ~0xfull, |
| 5256 |
dev_info); |
| 5257 |
pvr_write_draw_indirect_elements_base_instance2_write_vdm( |
| 5258 |
buffer, |
| 5259 |
program->index_list_addr_buffer); |
| 5260 |
pvr_write_draw_indirect_elements_base_instance2_flush_vdm( |
| 5261 |
buffer, |
| 5262 |
program->index_list_addr_buffer); |
| 5263 |
pvr_write_draw_indirect_elements_base_instance2_num_views( |
| 5264 |
buffer, |
| 5265 |
program->num_views); |
| 5266 |
pvr_write_draw_indirect_elements_base_instance2_idx_stride( |
| 5267 |
buffer, |
| 5268 |
program->index_stride); |
| 5269 |
pvr_write_draw_indirect_elements_base_instance2_idx_base( |
| 5270 |
buffer, |
| 5271 |
program->index_buffer); |
| 5272 |
pvr_write_draw_indirect_elements_base_instance2_idx_header( |
| 5273 |
buffer, |
| 5274 |
program->index_block_header); |
| 5275 |
pvr_write_draw_indirect_elements_base_instance2_immediates( |
| 5276 |
buffer); |
| 5277 |
} |
| 5278 |
} else { |
| 5279 |
pvr_write_draw_indirect_elements2_di_data(buffer, |
| 5280 |
program->arg_buffer & |
| 5281 |
~0xfull, |
| 5282 |
dev_info); |
| 5283 |
pvr_write_draw_indirect_elements2_write_vdm( |
| 5284 |
buffer, |
| 5285 |
program->index_list_addr_buffer); |
| 5286 |
pvr_write_draw_indirect_elements2_flush_vdm( |
| 5287 |
buffer, |
| 5288 |
program->index_list_addr_buffer); |
| 5289 |
pvr_write_draw_indirect_elements2_num_views(buffer, |
| 5290 |
program->num_views); |
| 5291 |
pvr_write_draw_indirect_elements2_idx_stride(buffer, |
| 5292 |
program->index_stride); |
| 5293 |
pvr_write_draw_indirect_elements2_idx_base(buffer, |
| 5294 |
program->index_buffer); |
| 5295 |
pvr_write_draw_indirect_elements2_idx_header( |
| 5296 |
buffer, |
| 5297 |
program->index_block_header); |
| 5298 |
pvr_write_draw_indirect_elements2_immediates(buffer); |
| 5299 |
} |
| 5300 |
break; |
| 5301 |
case 3: |
| 5302 |
if (program->support_base_instance) { |
| 5303 |
if (program->increment_draw_id) { |
| 5304 |
pvr_write_draw_indirect_elements_base_instance_drawid3_di_data( |
| 5305 |
buffer, |
| 5306 |
program->arg_buffer & ~0xfull, |
| 5307 |
dev_info); |
| 5308 |
pvr_write_draw_indirect_elements_base_instance_drawid3_write_vdm( |
| 5309 |
buffer, |
| 5310 |
program->index_list_addr_buffer); |
| 5311 |
pvr_write_draw_indirect_elements_base_instance_drawid3_flush_vdm( |
| 5312 |
buffer, |
| 5313 |
program->index_list_addr_buffer); |
| 5314 |
pvr_write_draw_indirect_elements_base_instance_drawid3_num_views( |
| 5315 |
buffer, |
| 5316 |
program->num_views); |
| 5317 |
pvr_write_draw_indirect_elements_base_instance_drawid3_idx_stride( |
| 5318 |
buffer, |
| 5319 |
program->index_stride); |
| 5320 |
pvr_write_draw_indirect_elements_base_instance_drawid3_idx_base( |
| 5321 |
buffer, |
| 5322 |
program->index_buffer); |
| 5323 |
pvr_write_draw_indirect_elements_base_instance_drawid3_idx_header( |
| 5324 |
buffer, |
| 5325 |
program->index_block_header); |
| 5326 |
pvr_write_draw_indirect_elements_base_instance_drawid3_immediates( |
| 5327 |
buffer); |
| 5328 |
} else { |
| 5329 |
pvr_write_draw_indirect_elements_base_instance3_di_data( |
| 5330 |
buffer, |
| 5331 |
program->arg_buffer & ~0xfull, |
| 5332 |
dev_info); |
| 5333 |
pvr_write_draw_indirect_elements_base_instance3_write_vdm( |
| 5334 |
buffer, |
| 5335 |
program->index_list_addr_buffer); |
| 5336 |
pvr_write_draw_indirect_elements_base_instance3_flush_vdm( |
| 5337 |
buffer, |
| 5338 |
program->index_list_addr_buffer); |
| 5339 |
pvr_write_draw_indirect_elements_base_instance3_num_views( |
| 5340 |
buffer, |
| 5341 |
program->num_views); |
| 5342 |
pvr_write_draw_indirect_elements_base_instance3_idx_stride( |
| 5343 |
buffer, |
| 5344 |
program->index_stride); |
| 5345 |
pvr_write_draw_indirect_elements_base_instance3_idx_base( |
| 5346 |
buffer, |
| 5347 |
program->index_buffer); |
| 5348 |
pvr_write_draw_indirect_elements_base_instance3_idx_header( |
| 5349 |
buffer, |
| 5350 |
program->index_block_header); |
| 5351 |
pvr_write_draw_indirect_elements_base_instance3_immediates( |
| 5352 |
buffer); |
| 5353 |
} |
| 5354 |
} else { |
| 5355 |
pvr_write_draw_indirect_elements3_di_data(buffer, |
| 5356 |
program->arg_buffer & |
| 5357 |
~0xfull, |
| 5358 |
dev_info); |
| 5359 |
pvr_write_draw_indirect_elements3_write_vdm( |
| 5360 |
buffer, |
| 5361 |
program->index_list_addr_buffer); |
| 5362 |
pvr_write_draw_indirect_elements3_flush_vdm( |
| 5363 |
buffer, |
| 5364 |
program->index_list_addr_buffer); |
| 5365 |
pvr_write_draw_indirect_elements3_num_views(buffer, |
| 5366 |
program->num_views); |
| 5367 |
pvr_write_draw_indirect_elements3_idx_stride(buffer, |
| 5368 |
program->index_stride); |
| 5369 |
pvr_write_draw_indirect_elements3_idx_base(buffer, |
| 5370 |
program->index_buffer); |
| 5371 |
pvr_write_draw_indirect_elements3_idx_header( |
| 5372 |
buffer, |
| 5373 |
program->index_block_header); |
| 5374 |
pvr_write_draw_indirect_elements3_immediates(buffer); |
| 5375 |
} |
| 5376 |
break; |
| 5377 |
} |
| 5378 |
} |
| 5379 |
} |