• 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
Papadopol

Few question about DirectX 11

13 posts in this topic

Hi. Im learning DirectX 11 and graphic programming and I want to understand everything before I go further. So I'll might ask some stupid question here and I'll be glad if you could help a noob.

1. The vertices order in a buffer for a triangle matter in any way (assuming the the mapping vertex-uv-etc is correct) excepting optimisation?
2. If I want to optimise for vertex cache I need to render front to back objects, traingles or vertices ? Assuming that I prefer rendering huge buffers (seems that improves dramtically the performance) intead of small buffers does the vertice order matter ?
If I have a SINGLE huge vertex buffer the GPU automatically cuts unseen vertices with CullFaces and I dont need any kind of optimisation ? Optimisations are for sorting separated vertex buffers ?
3. Is there any advantage using index buffer and split in more buffer, one for vertices, one for UVs, one for normals ? If yes how can I detect offline algoritmicaly on my mesh if is a fps boost ?
4. What tools is best for debugging low level GPU performance with those kind of optimisation? (Im using Visual Studio 2010, DirectX 11 SDK, SM 5.0) Edited by Papadopol
0

Share this post


Link to post
Share on other sites
1) That entirely depends on your primitive topology. [url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb205124(v=vs.85).aspx"]http://msdn.microsof...4(v=vs.85).aspx[/url]
Assuming you're referring to an indexed triangle list, which is the most sensitive to vertex ordering (in terms of vertex cache performance), then the answer is no. As long as your indices are in the correct order, the vertex buffer can be in any order. That's why optimization is important. If you're sending in indices like (1, 1049, 2, 510, 16, 53), the vertex cache isn't going to do you much good.

2) Like I said above, the vertex cache only helps you if you're taking advantage of temporal locality with your indexing. More simply put, make sure your index buffer references specific indices as much as possible before moving on in the buffer. It doesn't matter what your object rendering order is. Although the GPU will cull triangles eventually, it's not until late in the pipeline. It's much better to use coarse-grained methods like frustum culling for entire objects.

3) According to the MSDN docs, using multiple streams is a bit slower, in the usual case, but it can be a huge advantage in certain situations. For example, if you're rendering a depth pass for a shadow map or for deferred rendering, you don't want to pass in the entire interleaved vertex to a shader that only cares about the position. Using multiple streams in this situation allows you to just bind the position stream and use that, saving tons of bandwidth.

4. I use PIX, which is ok. I haven't delved much into the vendor specific tools yet. Edited by ZBethel
1

Share this post


Link to post
Share on other sites
So in a "common" mesh rendering if separate buffers is slow I never need Index Buffers as I use vertices buffers that has UV, normal maps etc ?
I dont see a case where a vertice is identical to another by vertex position, uv map, etc.

Nevermind, I fot the idea. Indexing vertices is not for skiping identical vertices but for reusing vertices in the vertex cache.


LE:
[url="http://fgiesen.wordpress.com/2011/07/03/a-trip-through-the-graphics-pipeline-2011-part-3/"]http://fgiesen.wordp...ne-2011-part-3/[/url]

If I understand correctly, I just use batches of vertices meaning Ill reorder the vertices in groups of 32 vertices maximum but in only big buffer? I really dont understand what a batch is. Is a render call with a different buffer or a potion of vertices in a vertex buffer? Edited by Papadopol
0

Share this post


Link to post
Share on other sites
Im reading a file and I'm having some problmes reading some variables

text file is like that:

[code]

chars count=191
char id=32 x=72 y=77 width=1 height=1 xoffset=0 yoffset=26 xadvance=8 page=0 chnl=15
etc..

[/code]

Code in my program:
[code]


while ( fontFile.good() ) {


getline (fontFile,line);

//search for number of characters variables
//

string toFind = "chars count="; // what sould I search in the current line
found = line.find(toFind); // where the text to fond is located

if(found != -1) {

int count = toFind.size() + found; // Where the variable starts
// So far so good, it seems it founds the correct location where the number is starting



// Here goes the problems
// I dont know hot to find out when the number is finished. I guess that should work with newline character but it doesnt
//


// Assertion failed here
// Seems it doesnt find newline as I resize line string and also gives me asserion failed
while (line[count] != '\n') {
count = count+1;

}



}
[/code]
0

Share this post


Link to post
Share on other sites
If I were you, I'd use the extraction operator with the ifstream (>>) and something like
[source lang="cpp"]while (c != '=') {
fontFile.get( c ); //Read until the last char read was the (=)-sign
}

//At this point "191" should be first in the ifstream buffer

fontFile >> count; //Read the integer to a variable[/source]

Of course, c is of type char, and count of type int.

Hope this works! Edited by SamiHuutoniemi
0

Share this post


Link to post
Share on other sites
I'd advise using either a binary file or some well-formatted text format (like XML) for which you can just download and use a parser library instead. Plain text formats are - IMO - hugely overrated and can often add unneeded complexity and make your program more error prone. Yes, they do have an advantage of being human-readable and human-editable, but that does need to be balanced against the cost. Defining your own plain text formats is even worse as you have a high risk of needing to add another text parser to your program each time you create another file type. Plain text formats in general are much slower to read and parse than binary files (this can become very significant when you start getting to large files) and using a parser library for something like XML will at least mean that you have a chance that the library is reasonably well-optimized. If it's a well-rated library and you get a bug you can have stronger certainty of where the bug is (i.e. in your code) too.
1

Share this post


Link to post
Share on other sites
Ok, going binary mode still having some problems:
Here is some binary mode documentation for Bitmap Font Generator [url="http://bobcat-games.net/doc/file_format.html#bin"]http://bobcat-games....format.html#bin[/url]

I dont know how to read the first variable

[code]

HANDLE hFile;
hFile = CreateFile (L"media\\fonts\\binary.fnt",
GENERIC_READ,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
MessageBox(NULL,L"Failed opening the binary file",L"error",NULL);
CloseHandle (hFile);
return;
}

DWORD dwBytesRead;
int fontsize=0;
ReadFile (hFile, &fontsize, 2, &dwBytesRead, NULL);
// I dont get the font size;

CloseHandle (hFile);
[/code] Edited by Papadopol
0

Share this post


Link to post
Share on other sites
I managed to load the binary file but no matter how hard I try it seems that the font is blurry. I unchecked "Font Smoothing" from Bitmap font generator but it seems it goes to the other extreme. I exported the font in a big size (40) do I'll have more pixel information and after that I've created triangles sized by UV coordonated and it seems I'm mapping 1:1 to the quad. When I create the quads the values of UVs are multyplied woth 0.002f. Then I use a matrix multiplication for scaling again regarding my need. Also without the scaling the font is still kind of blurry.
Any sugestion for sharpening the font?
[img]http://bobcat-games.net/font2.jpg[/img]



[img]http://bobcat-games.net/FONt.jpg[/img] Edited by Papadopol
0

Share this post


Link to post
Share on other sites
Looks the same with any filter in the sample.

[code]

D3D11_SAMPLER_DESC samplerDesc;
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.MipLODBias = 0.0f;
samplerDesc.MaxAnisotropy = 0;
samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
samplerDesc.BorderColor[0] = 0;
samplerDesc.BorderColor[1] = 0;
samplerDesc.BorderColor[2] = 0;
samplerDesc.BorderColor[3] = 0;
samplerDesc.MinLOD = 0;
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
[/code] Edited by Papadopol
0

Share this post


Link to post
Share on other sites
Also witout font smothing and Dx filtering
[url="http://bobcat-games.net/nosmoth.jpg"][img]http://bobcat-games.net/nosmoth.jpg[/img][/url] Edited by Papadopol
0

Share this post


Link to post
Share on other sites
Also how can I display those quads in the same size even if I resize the window on change the resolution ?
Assuming I dont care about about window resizing. A monitor with a native resolution of 1024x768 will display a quad in the same ratio as I see it on my native resolution of 1920x1200 ? Edited by Papadopol
0

Share this post


Link to post
Share on other sites
[quote name='Papadopol' timestamp='1344181753' post='4966378']
Looks the same with any filter in the sample.

[code]

D3D11_SAMPLER_DESC samplerDesc;
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.MipLODBias = 0.0f;
samplerDesc.MaxAnisotropy = 0;
samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
samplerDesc.BorderColor[0] = 0;
samplerDesc.BorderColor[1] = 0;
samplerDesc.BorderColor[2] = 0;
samplerDesc.BorderColor[3] = 0;
samplerDesc.MinLOD = 0;
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
[/code]
[/quote]

Ok, stupid question, but do you SET the sampler state? Almost sounds as if you do not.

[quote name='Papadopol' timestamp='1344182923' post='4966387']
Also how can I display those quads in the same size even if I resize the window on change the resolution ?
Assuming I dont care about about window resizing. A monitor with a native resolution of 1024x768 will display a quad in the same ratio as I see it on my native resolution of 1920x1200 ?
[/quote]

You can, but you would have to do the calculations in your program.
1

Share this post


Link to post
Share on other sites
Yes, actually I didnt set the sampler state. Thank you for pointing that.
Another questions:
If I have a class and I want to debug to a file or to a messagebox etc is ok to do that with a define ?
For exemple:
[code]
#define DEBUG 0

//some code that makes something
//..

#if DEBUG == 1
//write debug information about the code above to a file
#endif

// other lines of code
// ....
#if DEBUG == 1
//write debug information about the code
#endif
[/code]

I know that are many logical ways to do that but I wonder wich one is better and used by a programmer.

Thanks. Edited by Papadopol
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