• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
SagoO

How to read vertex array in vertex shader?

6 posts in this topic

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 =.=
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
[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.

0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
[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]

0

Share this post


Link to post
Share on other sites
[quote name='SagoO' timestamp='1300445068' post='4787408']
[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]
[/quote]

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.
0

Share this post


Link to post
Share on other sites
[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....
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0