Lib/SourceTranslate.cpp
/**
 * Generate code to add an offset to the uniforms which are pointers.
 *
 * The calculated offset is assumed to be in ACC0
 */
Generate code to add an offset to the uniforms which are pointers.
The calculated offset is assumed to be in ACC0
Generate code to add an offset to the uniforms which are pointers . The calculated offset is assumed to be in ACC0
Instr::List add_uniform_pointer_offset(Instr::List &code) {
  using namespace V3DLib::Target::instr;
  Instr::List ret;
  ret << mov(ACC0, ELEM_ID).comment("Initialize uniform ptr offsets")
      << shl(ACC0, ACC0, 2);            
  for (int index = 0; index < code.size(); ++index) {
    auto &instr = code[index];
    if (!instr.isUniformLoad()) break;  
    if (instr.isUniformPtrLoad()) {
      ret << add(rf((uint8_t) index), rf((uint8_t) index), ACC0);
    }
  }
  ret.back().comment("End initialize uniform ptr offsets");
  return ret;
}
Instr :: List add_uniform_pointer_offset ( Instr :: List & code ) { using namespace V3DLib :: Target :: instr ; Instr :: List ret ; ret << mov ( ACC0 , ELEM_ID ) . comment ( " " ) << shl ( ACC0 , ACC0 , 2 ) ; for ( int index = 0 ; index < code . size ( ) ; ++ index ) { auto & instr = code [ index ] ; if ( ! instr . isUniformLoad ( ) ) break ; if ( instr . isUniformPtrLoad ( ) ) { ret << add ( rf ( ( uint8_t ) index ) , rf ( ( uint8_t ) index ) , ACC0 ) ; } } ret . back ( ) . comment ( " " ) ; return ret ; }
Generate code to add an offset to the uniforms which are pointers.
Generate code to add an offset to the uniforms which are pointers .
// offset = 4 * vector_id; // offset now in ACC0 // add the offset to all the uniform pointers // Assumption: uniform loads always at top