Jump to content

  • Log In with Google      Sign In   
  • Create Account

How to read vertex array in vertex shader?


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.

  • You cannot reply to this topic
6 replies to this topic

#1 SagoO   Members   -  Reputation: 100

Like
0Likes
Like

Posted 17 March 2011 - 11:44 AM

Hi,

I have a program which will send thousands of array with size 2048 bytes each array. I uses VBO here.

for(p=0;p<noOfpacket;p++){

		for(q=0;q<2048;q++){
			gpu_payload[q] = packet_payload[p][q];
		}
		glGenBuffersARB(1, &vboID[p]);
		glBindBufferARB(GL_ARRAY_BUFFER_ARB, vboID[p]);
		glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(gpu_payload), gpu_payload, GL_STATIC_DRAW_ARB);

	}

After I send the data into the buffer, I want to process each of the array by using vertex shader. How to manipulate the vertex array in lower level?
Is it the vertex shader able to process each buffer object in parallel? That is what I want to reach.

Help please =.=

Sponsor:

#2 lc_overlord   Members   -  Reputation: 436

Like
0Likes
Like

Posted 17 March 2011 - 01:30 PM

Not sure what your trying to do here so i am gonna give as a general answer as i can
The vertex shader can't process all the buffer objects in paralell, but it does process each vertex in parallel (spread across the available shader units on your graphics card), also you can't directly manipulate the buffers, just whatever output you decide to render.
You can however use the transform feedback mode that will pass a vertex buffer trough the vertex and geometry shader and return it to another buffer.
Also using separate vertex buffers like that seems like a waste, try to pack several packets into one buffer, you should be able to fit at least 30 in each.
If there is anything specific you want to know then please give a more detailed description of what you want to do.

#3 SagoO   Members   -  Reputation: 100

Like
0Likes
Like

Posted 17 March 2011 - 08:47 PM

Not sure what your trying to do here so i am gonna give as a general answer as i can
The vertex shader can't process all the buffer objects in paralell, but it does process each vertex in parallel (spread across the available shader units on your graphics card), also you can't directly manipulate the buffers, just whatever output you decide to render.
You can however use the transform feedback mode that will pass a vertex buffer trough the vertex and geometry shader and return it to another buffer.
Also using separate vertex buffers like that seems like a waste, try to pack several packets into one buffer, you should be able to fit at least 30 in each.
If there is anything specific you want to know then please give a more detailed description of what you want to do.




Thanks for you reply. Okay..I explain more detail about my project. I am doing the simple deep packet inspection on the payload of the packet by using CPU and GPU. I will getting all the packets in one time.Then, send the packets into the buffer. I already have the algorithm to do the pattern matching in CPU using if--else statement and looping only. What I am doing was just a simple string matching. So, I store all the packets into 2-dimensional array. Eg: payload[N][2048]---> N = number of packets; 2048 --> 2048 bytes of each packets.

Since you say vertex shader process each vertex in parallel, how I sent these array into each vertex so that I can use it to process all the vertex in parallel. So, if pattern is found, I will change all the value of that vertex to '0'. Then, I read it out again. Everytime I read a consequences of 2048 times of '0', it means that packets has a pattern found. That is it.



#4 lc_overlord   Members   -  Reputation: 436

Like
0Likes
Like

Posted 18 March 2011 - 04:28 AM

actually in that case i think it might be better to put all the packets in a 2048xN texture instead as it would allow you to access every packet in the fragment shader, then all you just render a line or a quad matching the output you like (you take it's coordinates and use it on the texture in one or more axis) and finally use glReadPixels to get the data.

#5 SagoO   Members   -  Reputation: 100

Like
0Likes
Like

Posted 18 March 2011 - 04:44 AM

actually in that case i think it might be better to put all the packets in a 2048xN texture instead as it would allow you to access every packet in the fragment shader, then all you just render a line or a quad matching the output you like (you take it's coordinates and use it on the texture in one or more axis) and finally use glReadPixels to get the data.



Do you means texture buffer? I dun wan to render any display. How about I create one-dimensional texture objects to store those array? Eg: If I have 100 packets, I create 100 texture objects. Then, use shader to process every texture object in parallel. Will this work?



#6 lc_overlord   Members   -  Reputation: 436

Like
0Likes
Like

Posted 18 March 2011 - 06:40 AM

Do you means texture buffer? I dun wan to render any display. How about I create one-dimensional texture objects to store those array? Eg: If I have 100 packets, I create 100 texture objects. Then, use shader to process every texture object in parallel. Will this work?


no just a plain old texture, you can use an FBO to render to, that way you don't have to have any output.
A 1 dimensional array could work but it's far easier to just cram it into a 2048x2048 texture, that way you have packets in one dimension and the data in one, what works best depends on exactly your algorithm, but that is something you have to find out for yourself.

Another thing to try could be either Cuda or openCL as they are more adept to this kind of work.

#7 SagoO   Members   -  Reputation: 100

Like
0Likes
Like

Posted 18 March 2011 - 07:16 AM

no just a plain old texture, you can use an FBO to render to, that way you don't have to have any output.
A 1 dimensional array could work but it's far easier to just cram it into a 2048x2048 texture, that way you have packets in one dimension and the data in one, what works best depends on exactly your algorithm, but that is something you have to find out for yourself.

Another thing to try could be either Cuda or openCL as they are more adept to this kind of work.


Ya.I know about Cuda and openCL. I would like to try them if my budget is allowed. =.=

However, my only choice is to use openGL.

Back to topic-->

In short, I create a 2048x2048 textures. I initialize all the textures values = 1. After that, I pass the data into the texture accordingly. Send the texture into buffer.Those with value = 1 definitely is not my data so that I can recognize it.

I process the texture line by line in parallel. Those line with pattern found I change the value to 0. After that, I map out the whole texture to CPU and read it again. Then, I would know which data has pattern matched.

So that is the program flow I expect. However, I not sure what kind of function and concept should be used.

May be I try to use texture buffer object?However, how I manipulate the value of texture that had sent into the buffer object in shader program?

Eg:

I have this texture --> texture[2048]2048] = {...};

In CPU, I jz use if else and loop to search for pattern. After I send tis into the buffer, how I program the shader ? How I use the texture value again since I have to compare the value of the texture.

Eg:

for(int i = 0;i<2048;i++){
for(int j=0;j<2048;j++){

if( texture[i][j] = 12)
//do sth;
}
}

How i perform this task in the shader program since I cannot use texture[i][j] anymore. I really get mad with this....




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