Project

General

Profile

« Previous | Next » 

Revision de77a6c5

Added by Leszek Koltunski over 3 years ago

Introduce another Uniform Block Object. Now we can have much more vertex and fragment effects - up their default number to 100.

View differences:

src/main/java/org/distorted/library/effectqueue/EffectQueue.java
25 25
import org.distorted.library.main.DistortedLibrary;
26 26
import org.distorted.library.main.InternalMaster;
27 27
import org.distorted.library.main.InternalStackFrameList;
28
import org.distorted.library.uniformblock.UniformBlockFloatUniforms;
29
import org.distorted.library.uniformblock.UniformBlockIntUniforms;
28 30

  
29 31
import java.util.ArrayList;
30 32
import java.util.HashMap;
......
39 41
  {
40 42
  public static final int MAIN_VARIANTS = 4; // Number of Main program variants (ATM 4: MAIN, MAIN OIT, PREPROCESS, FULL)
41 43

  
42
  static final int PROP_VERT_UBO_BINDING = 5;
43
  static final int PROP_FRAG_UBO_BINDING = 6;
44
  static final int VERT_INT_UBO_BINDING = 5;
45
  static final int VERT_FLO_UBO_BINDING = 6;
46
  static final int FRAG_INT_UBO_BINDING = 7;
47
  static final int FRAG_FLO_UBO_BINDING = 8;
44 48

  
45 49
  private static final int CREATE = 0;
46 50
  private static final int ATTACH = 1;
......
50 54
  long mTime;
51 55
  int mNumEffects;              // 'ToBe' will be more than mNumEffects if doWork() hasn't
52 56
  private int mNumEffectsToBe;  // added them yet (or less if it hasn't removed some yet)
53
  private final int mNumFloatUniforms;
54 57
  Effect[] mEffects;
55 58

  
56
  float[] mFloatUniforms;
57
  UniformBlockProperties mUBP;
59
  UniformBlockFloatUniforms mUBF;
60
  UniformBlockIntUniforms mUBI;
58 61

  
59 62
  private long mID;
60 63
  private final int mIndex;
......
83 86
   
84 87
  EffectQueue(int numFloatUniforms, int numIntUniforms, int index)
85 88
    {
86
    mCreated          = false;
87
    mTime             = 0;
88
    mID               = 0;
89
    mNumEffects       = 0;
90
    mNumEffectsToBe   = 0;
91
    mIndex            = index;
92
    mNumFloatUniforms = numFloatUniforms;
93

  
94
    mUBP  = new UniformBlockProperties(numIntUniforms);
89
    mCreated        = false;
90
    mTime           = 0;
91
    mID             = 0;
92
    mNumEffects     = 0;
93
    mNumEffectsToBe = 0;
94
    mIndex          = index;
95

  
95 96
    mJobs = new ArrayList<>();
96 97

  
97 98
    mJobs.add(new Job(CREATE,numFloatUniforms,numIntUniforms, false,null)); // create the stuff that depends on max number
......
105 106
    {
106 107
    if( !source.mCreated )
107 108
      {
108
      mCreated          = false;
109
      mTime             = 0;
110
      mID               = 0;
111
      mNumEffects       = 0;
112
      mNumEffectsToBe   = 0;
113
      mIndex            = source.mIndex;
114
      mNumFloatUniforms = source.mNumFloatUniforms;
115

  
116
      mUBP  = new UniformBlockProperties(source.mUBP);
109
      mCreated        = false;
110
      mTime           = 0;
111
      mID             = 0;
112
      mNumEffects     = 0;
113
      mNumEffectsToBe = 0;
114
      mIndex          = source.mIndex;
115

  
117 116
      mJobs = new ArrayList<>();
118 117

  
119 118
      int numJobs = source.mJobs.size();
......
128 127
      }
129 128
    else
130 129
      {
131
      mCreated          = true;
132
      mTime             = source.mTime;
133
      mID               = source.mID;
134
      mNumEffects       = source.mNumEffects;
135
      mNumEffectsToBe   = source.mNumEffectsToBe;
136
      mIndex            = source.mIndex;
137
      mNumFloatUniforms = source.mNumFloatUniforms;
138

  
139
      mUBP  = new UniformBlockProperties(source.mUBP);
130
      mCreated        = true;
131
      mTime           = source.mTime;
132
      mID             = source.mID;
133
      mNumEffects     = source.mNumEffects;
134
      mNumEffectsToBe = source.mNumEffectsToBe;
135
      mIndex          = source.mIndex;
136

  
140 137
      mJobs = new ArrayList<>();
141 138

  
142 139
      int max = InternalStackFrameList.getMax(mIndex);
143 140

  
144 141
      if( max>0 )
145 142
        {
146
        mEffects       = new Effect[max];
147
        mFloatUniforms = new float[max*source.mNumFloatUniforms];
143
        mEffects= new Effect[max];
144
        mUBI  = new UniformBlockIntUniforms(source.mUBI);
145
        mUBF  = new UniformBlockFloatUniforms(source.mUBF);
148 146

  
149 147
        if( mNumEffects>=0 )
150 148
          {
......
255 253
      mNumEffects--;
256 254
      mEffects[pos].remQueue(this);
257 255
      System.arraycopy(mEffects, pos+1, mEffects, pos, mNumEffects-pos);
258
      mUBP.remove(pos, mNumEffects);
256
      mUBI.remove(pos, mNumEffects);
259 257
      mEffects[mNumEffects] = null;
260 258
      }
261 259
    }
......
265 263
  private void addNow(int pos, Effect effect)
266 264
    {
267 265
    mEffects[pos] = effect;
268
    mUBP.addOrdinal(pos, effect.getName().ordinal() );
266
    mUBI.addOrdinal(pos, effect.getName().ordinal() );
269 267
    effect.addQueue(this);
270 268

  
271 269
    if( mIndex==EffectType.VERTEX.ordinal() )
272 270
      {
273
      mUBP.addAssociations(pos,effect);
271
      mUBI.addAssociations(pos,effect);
274 272
      }
275 273
    }
276 274

  
......
413 411
      {
414 412
      if (mEffects[j].getID() == effectID)
415 413
        {
416
        mUBP.addAssociations(j,mEffects[j]);
414
        mUBI.addAssociations(j,mEffects[j]);
417 415
        }
418 416
      }
419 417
    }
......
422 420

  
423 421
  public void markForDeletion()
424 422
    {
425
    mUBP.markForDeletion();
423
    mUBI.markForDeletion();
424
    mUBF.markForDeletion();
426 425
    }
427 426

  
428 427
///////////////////////////////////////////////////////////////////////////////////////////////////
......
442 441
        case CREATE: int max = InternalStackFrameList.getMax(mIndex);
443 442
                     if( max>0 )
444 443
                       {
445
                       mEffects       = new Effect[max];
446
                       mFloatUniforms = new float[max*job.num1];
447
                       mUBP           = new UniformBlockProperties(job.num2);
444
                       mEffects= new Effect[max];
445
                       mUBF    = new UniformBlockFloatUniforms(job.num1, max);
446
                       mUBI    = new UniformBlockIntUniforms  (job.num2, max);
448 447
                       }
449 448
                     mCreated = true;
450 449

  
......
462 461
                       else if( position<=mNumEffects )
463 462
                         {
464 463
                         System.arraycopy(mEffects, position, mEffects, position+1, mNumEffects-position);
465
                         mUBP.makeHole(position, mNumEffects);
464
                         mUBI.makeHole(position, mNumEffects);
466 465
                         addNow(position,job.effect);
467 466
                         mNumEffects++;
468 467
                         changed = true;

Also available in: Unified diff