data-oriented-design

Switching back and forth between Array of Structures (AoS) and Structure of Arrays (SoA)

倾然丶 夕夏残阳落幕 提交于 2019-12-04 03:42:17
One feature that plays a prominent role in many of the writings on data oriented design is that there are many cases where rather than AoS (array of structs): struct C_AoS { int foo; double bar; }; std::vector<C_AoS> cs; ... std::cout << cs[42].foo << std::endl; it is more efficient to arrange one's data in SoA (struct of arrays): struct C_SoA { std::vector<int> foo; std::vector<double> bar; }; C_SoA cs; ... std::cout << cs.foo[42] << std::endl; Now what I am looking for is a solution which would allow me to switch between AoS and SoA without changing the calling interface, i.e. that I could,

Which is most cache friendly?

那年仲夏 提交于 2019-12-04 02:02:08
I am trying to get a good grip on data oriented design and how to program best with the cache in mind. There's basically two scenarios that I cannot quite decide which is better and why - is it better to have a vector of objects, or several vectors with the objects atomic data? A) Vector of objects example struct A { GLsizei mIndices; GLuint mVBO; GLuint mIndexBuffer; GLuint mVAO; size_t vertexDataSize; size_t normalDataSize; }; std::vector<A> gMeshes; for_each(gMeshes as mesh) { glBindVertexArray(mesh.mVAO); glDrawElements(GL_TRIANGLES, mesh.mIndices, GL_UNSIGNED_INT, 0); glBindVertexArray(0)

Is my understanding of AoS vs SoA advantages/disadvantages correct?

删除回忆录丶 提交于 2019-12-02 18:23:31
I've recently been reading about AoS vs SoA structure design and data-oriented design . It's oddly difficult to find information about either, and what I have found seems to assume greater understanding of processor functionality than I possess. That said, what I do understand about the former topic in particular leads to some questions that I think I should be able to understand the answers to. Firstly, to make sure I am not basing my understanding off of a false premise, my understanding of the functionality and pros and cons of AoS vs SoA, as applied to a collection of 'Person' records with

If-statement vs function pointer

旧城冷巷雨未停 提交于 2019-11-30 03:12:21
问题 The goal is to change the behaviour in an event loop, depending on whether a checkbox is toggled on or off. The simplest way, that I can think of, is just to test the checkbox state each time the loop is run. // if-statement void action() { /* ... */ } void someLoop() { if (checkboxTrue) { action(); } // ... other stuff } Would the code be more performant and cleaner or in any other way better, if a function pointer was being used? Like this: // function pointer void action() { /* ... */ }

Is my understanding of AoS vs SoA advantages/disadvantages correct?

早过忘川 提交于 2019-11-28 21:26:57
问题 I've recently been reading about AoS vs SoA structure design and data-oriented design. It's oddly difficult to find information about either, and what I have found seems to assume greater understanding of processor functionality than I possess. That said, what I do understand about the former topic in particular leads to some questions that I think I should be able to understand the answers to. Firstly, to make sure I am not basing my understanding off of a false premise, my understanding of

What is data oriented design?

拈花ヽ惹草 提交于 2019-11-26 19:16:54
I was reading this article , and this guy goes on talking about how everyone can greatly benefit from mixing in data oriented design with OOP. He doesn't show any code samples, however. I googled this and couldn't find any real information as to what this is, let alone any code samples. Is anyone familiar with this term and can provide an example? Is this maybe a different word for something else? Erik Engheim First of all don't confuse this with data driven design. My understanding of Data Oriented Design is that it is about organizing your data for efficient processing. Especially with

What is data oriented design?

天涯浪子 提交于 2019-11-26 06:51:54
问题 I was reading this article, and this guy goes on talking about how everyone can greatly benefit from mixing in data oriented design with OOP. He doesn\'t show any code samples, however. I googled this and couldn\'t find any real information as to what this is, let alone any code samples. Is anyone familiar with this term and can provide an example? Is this maybe a different word for something else? 回答1: First of all don't confuse this with data driven design. My understanding of Data Oriented