SagoO

Members
  • Content count

    6
  • Joined

  • Last visited

Community Reputation

100 Neutral

About SagoO

  • Rank
    Newbie
  1. HI, I have create a offscreen rendering buffer. I have a fragment program jz simple as this: [code] static const char *fragment_source = { "void main(void)" "{" "gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);" "}" [/code] Then, I create a offscreen rendering FBO: [code] /*Create a fbo to perform offscreen rendering*/ glGenFramebuffersEXT(1,&fbo); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fbo); /*Create render object*/ glGenRenderbuffersEXT(1,&renderbuffer); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT,renderbuffer); glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,GL_RGBA,noOfpacket,size); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_RENDERBUFFER_EXT,renderbuffer); status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); switch(status) { case GL_FRAMEBUFFER_COMPLETE_EXT: printf("***FBO complete***\n\n"); break; default: fprintf(stderr, "Error: %s\n", gluErrorString(status)); break; } glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fbo); [/code] Then, I read the buffer: [code] /*Read values back*/ /*Set the target framebuffer to read*/ glReadBuffer(GL_COLOR_ATTACHMENT0_EXT); /*Read pixels from framebuffer to CPU buffer*/ glReadPixels(0,0,size,noOfpacket,GL_RGBA,GL_UNSIGNED_BYTE,result); checkError("glReadPixels error!"); printf("Data in frame buffer:\n"); for (i=0;i<noOfpacket*size;i++) printf("%d",result[i]); printf("\n\n"); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT,0); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0); [/code] Well. I got all zeros all the time in the frame buffer. That is impossible since my fragment should output something. I never unbound my FBO. So, the shader should render to the offscreen FBO. Any one face this problem before? Help please.... Thank for your reply.
  2. I have a texture 2048x2048. I want to process the texture line by line in parallel. But I dun know how to program my shader program. Shader can be used to process each vertex in parallel. But I dun understand how it works? Can anyone explain further?
  3. [quote name='lc_overlord' timestamp='1300452044' post='4787443'] 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. [/quote] 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....
  4. [quote name='lc_overlord' timestamp='1300444080' post='4787404'] 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. [/quote] [font="Arial"]Do you means texture buffer? I dun wan to render any display. [size=2]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?[/size][/font]
  5. [quote name='lc_overlord' timestamp='1300390220' post='4787132'] 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. [/quote] 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.
  6. Hi, I have a program which will send thousands of array with size 2048 bytes each array. I uses VBO here. [code] 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); } [/code] 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 =.=