• Create Account

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

4 replies to this topic

### #1slicer4ever  Crossbones+   -  Reputation: 2209

Like
0Likes
Like

Posted 23 June 2012 - 09:07 AM

hello everyone, i have a question on which approach would be faster/better overall.

currently my engine does not support any method of arranging 4x4 matrix's into a series of matrix's, so for uploading i do something like this:

float *ProjMatrix = //Projmatrix
float *ViewMatrix = //ViewMatrix
float *MeshMatrix = //MeshMatrix

glUniformMatrix4fv(ProjLoc, 1, 0, ProjMatrix);
glUniformMatrix4fv(ViewLoc, 1, 0, ViewMatrix);
glUniformMatrix4fv(MeshLoc, 1, 0, MeshMatrix);



however, i'm curious if doing the following would be faster:

float *ProjMatrix = //Projmatrix
float *ViewMatrix = //ViewMatrix
float *MeshMatrix = //MeshMatrix
float m[48];
memcpy(m, ProjMatrix, sizeof(float)*16);
memcpy(m+16, ViewMatrix, sizeof(float)*16);
memcpy(m+32, MeshMatrix, sizeof(float)*16);

glUniformMatrix4fv(matrixLoc, 3, 0, m);



i know i should test instead of asking, but i'm curious if this is something someone might already know?
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

### #2mhagain  Crossbones+   -  Reputation: 5593

Like
1Likes
Like

Posted 23 June 2012 - 10:55 AM

Given the frequency with which matrixes should need to be uploaded, there should be next to no measurable performance difference. What will give you extra performance is pre-multiplying p * v * m on the CPU and just loading one matrix - but that will come from reduced per-vertex calculations in your VS and not from just loading a single matrix.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.

### #3slicer4ever  Crossbones+   -  Reputation: 2209

Like
0Likes
Like

Posted 23 June 2012 - 12:41 PM

Given the frequency with which matrixes should need to be uploaded, there should be next to no measurable performance difference. What will give you extra performance is pre-multiplying p * v * m on the CPU and just loading one matrix - but that will come from reduced per-vertex calculations in your VS and not from just loading a single matrix.

hmm, interesting, would doing the multiplications at upload like so:

float *ProjMatrix = //Projmatrix
float *ViewMatrix = //ViewMatrix
float *MeshMatrix = //MeshMatrix
float pvm[16];
pvm = ProjMatrix*ViewMatrix*MeshMatrix; //yes, i know they are just floats

glUniformMatrix4fv(matrixLoc, 1, 0, pvm);

give me an overall increase in performance?

i could probably do p*v inside my camera class, instead of at each upload.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

### #4mhagain  Crossbones+   -  Reputation: 5593

Like
1Likes
Like

Posted 23 June 2012 - 01:49 PM

positionout = positionin * p * v * m;

You have:
positionout = positionin * pvm;

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.

### #5slicer4ever  Crossbones+   -  Reputation: 2209

Like
0Likes
Like

Posted 23 June 2012 - 02:30 PM

thanks for the information=-)
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS