Domanda

Im learning opengl and using examples of VBOs which consists of a color array, a vertex array, a normals array and index array to be used by GL.DrawElements() and the structure looks like(a dot mean next element/item):

 Rgba.Rgba.Rgba.....Xyz.Xyz.Xyz.Xyz....n1n2n3.n1n2n3.n1n2n3.....ijklmn.ijklmn.ijklmn

I need them to be used as:

 R.R.R.R.R....g.g.g.g.g......b.b.b.b.b.....a.a.a.a.a.a.....X.X.X.X.X.X....y.y.y.y.y.y..
 ...z.z.z.z.z.z.......n1.n1.n1.n1.n1.n1......n2.n2.n2.n2.n2.n2.n2......n3.n3.n3.n3.n3...
 ...i.i.i.i.i.i......j.j.j.j.j.j.j.j......k.k.k.k.k.k.k.k.k

because Im using buffers' data for opencl kernel as cl-gl-interop and the first type structure makes strided memory accesses which chops the performance of main memory access because Im using only one component of each element/item such as only "x" or only "r". But the second type structure is using all memory banks equally and fits for my needs. Is this kind of structure usable/suitable for opengl drawing operations?

È stato utile?

Soluzione

You normally pass images as textures. In your case you'd use either 3 separate textures or a 3 layer texture array which you combine into a RGB tuple in the fragment shader.

The geometry data (XYZ) you'd pass as 3 separate 1-component vertex attributes with 0 stride and each attribute offset pointing to the beginning of the respective data.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top