Project

General

Profile

« Previous | Next » 

Revision 80961fc1

Added by Leszek Koltunski about 3 years ago

Make the 'Component Associations' UBO (on most devices) twice smaller -
use the 'packed' layout and 'ivec2' in place of 'ivec4'.

This forces us to dynamically probe the 'Stride' - number of 4-byte entities that the UBO's 'ivec4' takes - and correct the already-constructed UniformBlockAssociation objects in case this turns out to be different than the expected 2, i.e. tightly-packed.

The point: this saves a lot of uniform space in th vertex shader, which lets us declare larger MAX_NUM_COMPONENTS - needed for the Gigaminx.

(and no, we cannot assume an UBO can hold at least 16KB since this is not the case on Samsung Galaxy J4+)

View differences:

src/main/java/org/distorted/library/mesh/MeshBase.java
51 51
   {
52 52
   private static final int ASSOC_UBO_BINDING  = 3;
53 53
   private static final int CENTER_UBO_BINDING = 4;
54
   public  static final int MAX_EFFECT_COMPONENTS= 98;
54
   public  static final int MAX_EFFECT_COMPONENTS= 242;
55 55

  
56 56
   // sizes of attributes of an individual vertex.
57 57
   private static final int POS_DATA_SIZE= 3; // vertex coordinates: x,y,z
......
94 94
   private float mInflate;
95 95
   private final UniformBlockAssociation mUBA;
96 96
   private UniformBlockCenter mUBC;
97
   private boolean mStrideCorrected;
98
   private static int mStride;
97 99

  
98 100
   DeferredJobs.JobNode[] mJobNode;
99 101

  
......
577 579
     {
578 580
     mCenterBlockIndex[variant]= GLES30.glGetUniformBlockIndex(programH, "componentCenter");
579 581
     mAssocBlockIndex[variant] = GLES30.glGetUniformBlockIndex(programH, "componentAssociation");
582

  
583
     if( mStride==0 )
584
       {
585
       String[] uniformNames = { "vComAssoc" };
586
       int[] indices = new int[1];
587
       int[] params  = new int[1];
588

  
589
       GLES30.glGetUniformIndices(programH, uniformNames, indices, 0);
590
       GLES30.glGetActiveUniformsiv( programH, 1, indices, 0, GLES30.GL_UNIFORM_ARRAY_STRIDE, params,0 );
591

  
592
       mStride = params[0]/4;
593
       }
580 594
     }
581 595

  
582 596
///////////////////////////////////////////////////////////////////////////////////////////////////
......
726 740
 */
727 741
   public void send(int programH, int variant)
728 742
     {
743
     if( !mStrideCorrected )
744
       {
745
       mStrideCorrected = true;
746
       mUBA.correctStride(mStride);
747
       }
748

  
729 749
     int indexA = mUBA.getIndex();
730 750
     GLES30.glBindBufferBase(GLES30.GL_UNIFORM_BUFFER, ASSOC_UBO_BINDING, indexA);
731 751
     GLES30.glUniformBlockBinding(programH, mAssocBlockIndex[variant], ASSOC_UBO_BINDING);

Also available in: Unified diff