Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The assignment inside the loop <em>could</em> be a problem, I'm not familiar with the library though. Moving it outside the for loop, and doing the field assignments manually might help. Moving the transformations outside the loop would help as well.</p> <p>Edit:</p> <p>This is more along the lines of what I was thinking.</p> <pre><code>// Apply Matrix glm::vec4 transformed; glm::mat4 translation = m_rotation * m_translation; for ( int i=0; i&lt;6; i++ ) { transformed.x = vertices[i].x; transformed.y = vertices[i].y; transformed.z = vertices[i].z; transformed.w = 1.f; // ? /* I can't find docs, but assume they have an in-place multiply transformed.mult(translation); // */ vertices[i].x = transformed.x; vertices[i].y = transformed.y; } </code></pre> <p>Maybe, just maybe, the assignment is keeping the compiler from inlining or unrolling something. I kind of guess that the multiply is hefty enough to bump this out of the instruction cache though. And really, if you start talking about the sizes of caches, you aren't going to be resilient across many platforms. </p> <p>You could try to duplicate some stack and make more, smaller loops.</p> <pre><code>glm::vec4 transformed[6]; for (size_t i = 0; i &lt; 6; i++) { transformed[i].x = vertices[i].x; transformed[i].y = vertices[i].y; transformed[i].z = vertices[i].z; transformed.w = 1.f; // ? } glm::mat4 translation = m_rotation * m_translation; for (size_t i = 0; i &lt; 6; i++) { /* I can't find docs, but assume they have an in-place multiply transformed.mult(translation); // */ } for (size_t i = 0; i &lt; 6; i++) { vertices[i].x = transformed[i].x; vertices[i].y = transformed[i].y; } </code></pre> <p>As Jason mentioned, unrolling these loops manually could be interesting.</p> <p>I really don't think that you'll see an order of magnitude improvement on any of these changes, though.</p> <p>I suspect that calling this function less is more important than making this function faster. The fact that you have this needsTransform check inside of this function makes me think that this is probably relevant.</p> <p>When you have high level concerns like this in your low level code, you end up just blindly calling this method over and over thinking that it is free. Whether or not that your assumptions about how often needsTransform is true could be wildly incorrect.</p> <p>The reality is that you should be just be calling this method once. You should applyTransform, when you want to applyTransform. You shouldn't call applyTransform when you <em>might</em> want to applyTransform. Interfaces should be a contract, treat them as such.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload