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

dario_ramos

Members
  • Content count

    80
  • Joined

  • Last visited

Community Reputation

135 Neutral

About dario_ramos

  • Rank
    Member
  1. OK, I ran PIX and here are some results. First, I selected "Statistics for each frame, using counterset" with a custom counter set which displayed FPS and %Processor Time. I got this:   [url=http://www.picamatic.com/view/9088792_screen1/][/URL] Yellow is %Processor Time, red is FPS. So if I understand correctly, virtually all of the frame time is consumed by the CPU. On the other hand, FPS oscillates wildly between 60 and below 25. That seems consistent with the flicker I experience (it doesn't happen all the time; it fluctuates). Then I closed the test program and looked at the timeline:   [url=http://www.picamatic.com/view/9088793_screen2/][/URL]   So it would seem I'm CPU bound, which seems to be consistent with %Processor Time being at 100%. First of all, is my analysis correct? Second, why does FPS vary so wildly? And then, how should I go about looking further into this? I thought of enabling draw timing and looking at a frame where instantaneous FPS is low, to see which calls consume more time.
  2. I got PIX working now; my test crashed on exit and it seems that messed up PIX's sampling. So now I'm learning how to profile and analyze the results properly, since I only used PIX's "Debug this pixel" feature before. I'll get back with results later.
  3. My application needs to capture and play a live video stream from an Epix imaging board hooked up to a camera. I use an unmanaged Direct3D9 device, with a vertex shader and pixel shader associated to an Effect.   In my development box, I emulate the imaging board by loading a video from a file into memory and launching a thread which supplies frame by frame to the application when requested. This works and looks great in my development box (Windows 7 x64, two monitors, each one hooked up to a NVIDIA GeForce 210 - two monitor, two video cards).   In our production box, however, the live capture exhibits a quite noticeable flicker. The production box has ONE NVidia GeForce 210 card which two outputs hooked to two monitors. Asides from that, hardware specs are a little below the development box (Dev has an i7 CPU, 4 GB RAM and Win7 x64, while Prod has an Intel G2020 with 2 GB RAM and Win XP x86).   I tried installing and running PIX in Prod, but it crashes when I exit my app. I tried all configurations I could think of but couldn't capture a single frame. First of all, I want to ascertain if this is really a performance issue. If it is so, I'd struggle with PIX or try nvPerfHUD to determine if the app is CPU or GPU bound.   But I'm at a loss now. How could I see if this is really a performance problem, or maybe I'm messing up some property in my Direct3D9 device?   // Set up the structure used to create the D3DDevice. We will create a // device with a zbuffer. ZeroMemory( &m_d3dpp, sizeof( m_d3dpp ) ); m_d3dpp.Windowed = TRUE; m_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; m_d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; m_d3dpp.EnableAutoDepthStencil = TRUE; // Let Direct3D create and manage z-buffer m_d3dpp.AutoDepthStencilFormat = D3DFMT_D16;   The camera is capturing at 25 FPS. My simulator works as fast as the CPU lets it, and in my dev box it runs at almost 60 FPS.   Edit: I render my images as textured quads; texture size is configurable. If an image is larger than the texture size, more than one quad will be needed.   Edit2: My application uses Windows Forms for its GUI, and the direct3d part is done as a C++/CLI class which inherits System.Windows.UserControl and wraps an unmanaged class which does the actual rendering. But I managed to make a smaller, all unmanaged test which reproduces the problem. I used plain WinAPI to render inside a window created with the CreateWindowEx function. And it still flickers...
  4.   It does look inconsistent out of context, doesn't it? It's actually OK since that call is wrapped inside a setter-style method which receives pNewVal as a parameter. The others don't have that style because they received a local variable with that name.   My original problem is solved now; I didn't know that it was necessary to call CommitChanges if you changed effect parameters while rendering a pass. I'll now apply the performance tips the other guys gave me and see how it goes.
  5. As I suspected, if you set an effect parameter while you're between Begin() and End() calls, you need to call CommitChanges for the effect to notice the change. So now that I call that function after setting the g_matWorld parameter, everything works fine again.   However, I now need to call CommitChanges for each of my texture quads. I'm gonna check with PIX, but isn't this inefficient? Is there another, more efficient, way to position my textured quads before drawing them?
  6. I used to handle transformation matrices (world, view, projection) at "device level", to say so. That is, I used calls like this:   m_pd3dDevice->SetTransform( D3DTS_WORLD, pNewVal ); m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView ); m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );  Everything was working perfectly that way. But when I added support for the HLSL shader model 3.0, I was forced to define a vertex shader (my effect wouldn't compile). So far, I hadn't needed  a vertex shader because there was no need for custom transformations at that level. Anyway, it seems that when you define your vertex shader, you must perform the world-view-projection transformation there. That was the way I understood it, correct me if I'm wrong. So my vertex and pixel shader ended up like this:   sampler2D Texture0; float4x4 g_matProjection; float4x4 g_matView; float4x4 g_matWorld; struct VertexShaderInput{ float4 Position : POSITION; float2 TexCoord : TEXCOORD0; }; struct VertexShaderOutput { float4 Position : POSITION; float2 TexCoord : TEXCOORD0; }; VertexShaderOutput BasicVertexShader( VertexShaderInput input ) { VertexShaderOutput output; output.Position = mul( input.Position, g_matWorld ); output.Position = mul( output.Position, g_matView ); output.Position = mul( output.Position, g_matProjection ); output.TexCoord = input.TexCoord; //Just pass it along return output; } struct PixelShaderOutput { float4 color : COLOR0; }; PixelShaderOutput PixelShaderFirstPass( VertexShaderOutput input ) { //Magic happens here //We use the tex2D function to sample Texture0 }   To make this work, I replaced the SetTransform calls with calls that set the appropiate effect variable, like so:   m_pd3dDevice->SetTransform( D3DTS_WORLD, pNewVal ); // Now  m_pEffect->setParameter( "g_matWorld", pNewVal ); m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );  //Now m_pEffect->setParameter( "g_matView", &matView ); m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );  //Now m_pEffect->setParameter( "g_matProjection", &matProj ); void CEffect::setParameter( const string& strName, const D3DXMATRIXA16 * newVal ) { if( !m_pEffect ) return; D3DXHANDLE handle; assert( handle = m_pEffect->GetParameterByName( NULL, strName.c_str() ) ); assert( SUCCEEDED( m_pEffect->SetMatrix( handle, newVal ) ) ); }  With this new setup, pan and zoom work, but when I draw my textured quads, they all end up in the same position, one on top of the other (I verified this using PIX, and I also checked that the world matrix is set right before drawing each quad, and with different values). I'm at a loss now. Did I misunderstand something about the way this should be done? The view and projection matrices are set BEFORE calling m_pEffect->Begin(), and the world transform is set between m_pEffect->Begin() and m_pEffect->End(). Could this be the reason?
  7. @[url="http://www.gamedev.net/user/105081-adam_42/"]Adam_42[/url]: It's an [color=#000000][font=arial, sans-serif][size=3]Nvidia quadro NVS 290, drivers version: [/size][/font][/color][color=#000000][font=arial, sans-serif][size=3]6.14.12.7533[/size][/font][/color] [color=#000000][font=arial, sans-serif][size=3]@Everyone: We made a little change and the error seems to have disappeared. When getting the viewport dimensions, we were using ::GetWindowRect instead of ::GetClientRect. Now that we're using the second function, the error seems to not happen anymore. We came up with this idea when we compared the differences between the client's software version and ours. If the error happens again, I'll try your suggestions, that is, updating graphic drivers first, checking debgu spew later.[/size][/font][/color]
  8. [quote name='kubera' timestamp='1335466667' post='4935168'] Often applications fail randomly on bad pointers. I think you know it... Maybe you would reinvestigate your code. [/quote] If that were the case, the app would most surely crash. But it doesn't. Sometimes it renders, sometimes it doesn't. It never crashes. Based on that, I ruled out access violations, undefined behavior, and the like. [quote name='kubera' timestamp='1335466667' post='4935168'] The other idea, not enough resources, VideoRAM. etc. Please consider checking the debug console, also. [/quote] Same consideration. If resources were running out, the app wouldn't recover, or would stop rendering completely. As for checking the debug output of the runtime, that would be great, but the error only happens in a client's machine where only the Direct3D redistributable is installed. Since we operate it remotely and it's in another country, installing software is a hassle. If there is a way to capture Direct3D debug output without installing anything, I'm all eyes. Anyway, as a last resort, we could install the SDK and PIX... When we get desperate enough [quote name='Adam_42' timestamp='1335469573' post='4935192'] It sounds possible that it's a hardware / driver issue. I'd try updating the driver on the machine that's failing first. If possible try replacing the graphics card too. [/quote] Good idea. It'll be quite a hassle, since we'll have to log remotely to the client machine, and maybe ask the operator over there to try changing the card. But I'll give it a shot and post back. [quote name='Adam_42' timestamp='1335469573' post='4935192'] Out of curiosity which card / driver version is causing the problems? [/quote] I'll post this info tomorrow when I log remotely.
  9. I have a mixed .NET application (managed and unmanaged code bridged by C++/CLI wrappers) which uses unmanaged Direct3D9 9.0c to do rendering inside a control which is wrapped inside a C++/CLI class which extends System.WIndows.Forns.UserControl. Everything has been working fine for years now, but I recently put another instance of this Direct3D9 control inside a new Windows Form. That is, I have two concurrent instances of the control. I had done that before and it worked, but now I have issues. Perhaps the problem was always there, but because it's related to a race condition, it started happening now... Ok, the details: When I try to render an image over a texture on the new instance of the control, sometimes it works, sometimes it doesn't. And when it doesn't, nothing is rendered, and from that point onwards, all Present calls fail (I log those failures). If I close the form and open it again, it might work or not. Nasty. If I use DXGetErrorString and DXGetErrorDescription, all I get is something like: EFAILED Undetermined error Not really helpful... To make matters worse, I can't reproduce the issue in my development environment; I only see it in a production box. As far as I know, the main reason Present fails like this is a Lost Device. But I implemented the usual scheme to handle that (I can post the code if necessary), and it seems like the device is not being lost... What else can I try?
  10. I have just written the vertex shader, and it doesn't crash, but now zooming and panning (which were done using the view and projection matrices) don't work, and I can see black lines between my texture quads. This is my code before adding the vertex shader (I used only a pixel shader); everything works fine: [code] struct PS_OUTPUT { float4 color : COLOR0; }; PS_OUTPUT ps2FirstPassIgnoringBackground( float2 vTexCoord : TEXCOORD0, float4 vColor : COLOR ) { PS_OUTPUT output; if( g_bEnableLinearFilter ) output.color = applyLinearFilter( vTexCoord, Texture0 ); else output.color = tex2D( Texture0, vTexCoord ); output.color = applyLutIgnoringBackground( output.color ); output.color = HideOverlappedPixels( output.color, vTexCoord ); return output; }[/code] Adding the vertex shader, I changed it to this (everything else remained just like it was) [code] //Other declarations omitted because they didn't change float4x4 g_matProjection; float4x4 g_matView; struct VS_OUTPUT { float4 pos : POSITION; float2 TextureUV : TEXCOORD0; }; VS_OUTPUT vs( float4 pos : POSITION, float2 vTexCoord0 : TEXCOORD0 ) { VS_OUTPUT output; output.pos = mul( pos, g_matView ); output.pos = mul( output.pos, g_matProjection ); output.TextureUV = vTexCoord0; return output; } struct PS_OUTPUT { float4 color : COLOR0; }; PS_OUTPUT ps2FirstPassIgnoringBackground( VS_OUTPUT input ) { PS_OUTPUT output; if( g_bEnableLinearFilter ) output.color = applyLinearFilter( input.TextureUV, Texture0 ); else output.color = tex2D( Texture0, input.TextureUV ); output.color = applyLutIgnoringBackground( output.color ); output.color = HideOverlappedPixels( output.color, input.TextureUV ); return output; } [/code] Now, instead of using SetTransform, I use this: [code] void CEffect::Configure( const CCamera& camera ) { setParameter( "g_matProjection", &camera.calculateProjectionMatrix() ); setParameter( "g_matView", &camera.calculateViewMatrix() ); } void CEffect::setParameter( const string& strName, const D3DXMATRIXA16 * newVal ) { if( !m_pEffect ) return; D3DXHANDLE handle; assert( handle = m_pEffect->GetParameterByName( NULL, strName.c_str() ) ); assert( SUCCEEDED( m_pEffect->SetMatrix( handle, newVal ) ) ); }[/code] Where did I mess up?
  11. [quote name='mhagain' timestamp='1322673503' post='4889131'] Yes, you do have to implement a vertex shader with SM 3.0, but it can be quite a simple shader. Just multiply the vertex position by your matrixes (you should premultiply the matrixes on the CPU although the Efects framework may pull that out as a pre-shader) and pass everything else through to the pixel shader; there are plenty of examples in the SDK to help you here. [/quote] Ok, sounds reasonable. I still have one doubt though: What about the view and projection matrix handling I'm currently doing in my D3DDevice? (the second code snippet in my first post) Should I stop doing that and leave it all up to the vertex shader? Instead of calling SetTransform for the ID3DDevice, I should update the vertex shader's matrices, shouldn't I?
  12. I have an application which renders using Direct3D9, more specifically Pixel Shaders via the Effect framework. I have a .fx file, with techniques for 2.0, 2.a and 2.b models. All these techniques have just a pixel shader compiled against the respective model, and I select the best one for the given GPU using the [i]FindNextValidTechnique [/i]function. So my techniques look like this: [code] technique compileFor2_b { pass P0 { PixelShader = compile ps_2_b ps2FirstPassIgnoringBackground(); } } [/code] However, if I try to write one of these for 3.0 or above, I get an error saying I must implement a vertex shader. The problem is that, according to what I read, and please correct me if I'm wrong, that would imply that view and projection would now have to be done in the vertex shader. Right now, I'm doing this: [code] void CD3DDevice::Configure( const CCamera& camera ) { D3DXMATRIXA16 matView = camera.calculateViewMatrix(); m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView ); D3DXMATRIXA16 matProj = camera.calculateProjectionMatrix(); m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj ); } [/code] So many questions... [list=1][*]Do I have to delete this method and implement its equivalent in a Vertex Shader for all techniques?[*]If the answer to 1 is yes, how do I do that? Or kindly point me to some book or resource. I've done some pixel shaders, but never a vertex shader.[*]What about cards which support Pixel Shaders but don't support Vertex Shaders? How do I provide a fallback mechanism?[/list]
  13. [quote name=[u]'[/u]Pomnico[u]'[/u]] Personally I wouldn't spend to effort on eliminating this redundant SetSamplerState. In my project I have removed all redundant calls from my side, but ignored those resulting from SetTechnique. If you are using standard Direct3D device, these are only warnings. As far as I know DirectX will ignore such state changes and they will not be processd to the GPU. If you are using pure device however (D3DCREATE_PUREDEVICE) above is not true and each call to set state will be processed to the device. In such a case you should by all means remove such redundant calls. The only way to remove them if you wish to do so, is to attach state manager to the effect (ID3DXEffect::SetStateManager). Generally you will have to implement all requests coming from techniques to set sampler, render etc. states in it. This will give you a possibility to check if a state needs to be changed. You can find more about state manager here: [url="http://msdn.microsoft.com/en-us/library/bb205833%28v=VS.85%29.aspx"]http://msdn.microsof...v=VS.85%29.aspx[/url] Hope this will help. [/quote] I'm using a pure device, so I guess I'll have to do what you say. Anyway, it bugs me that the Direct3D sample which uses the StateManager generates these warnings... Maybe the StateManager implementation it provides is a naive one and doesn't check for redundant calls. I hope that's the case. [quote name='mhagain' timestamp='1301481373' post='4792107'] I can confirm that the D3D runtime will filter redundant state changes on a non-pure device. There's more info about the whole state change mechanism here: [url="http://tomsdxfaq.blogspot.com/2002_07_01_archive.html"]http://tomsdxfaq.blo...01_archive.html[/url] [/quote] Thanks for the link, it clarified quite a few things. I'll start implementing a StateManager and post back when I'm done. Thanks for the ideas, guys
  14. [quote name='dario_ramos' timestamp='1300908140' post='4789610'] Well, I have just ran the StateManager sample app, and it gave a lot of SetRedundantState warnings... So I'm at a loss now. Perhaps it has to do with my GPU? It's an NVIDIA GeForce 8400 GS, and Direct3D9 seems to recognize it successfully (this is from the StateManager sample run): Edit: I forgot to mention that I'm using the June 2010 DirectX SDK [code] Direct3D9: :====> ENTER: DLLMAIN(010ee6e0): Process Attach: 00000c8c, tid=00001694 Direct3D9: :====> EXIT: DLLMAIN(010ee6e0): Process Attach: 00000c8c Direct3D9: (INFO) :Direct3D9 Debug Runtime selected. Direct3D9: (WARN) :No SW device has been registered. GetAdapterCaps fails. D3D9 Helper: IDirect3D9::GetDeviceCaps failed: D3DERR_NOTAVAILABLE 'StateManager.exe': Loaded 'C:\WINDOWS\system32\d3dref9.dll', Cannot find or open the PDB file Direct3D9: (INFO) :======================= Reference HWVP device selected Direct3D9: (INFO) :HalDevice Driver Style 9 Direct3D9: :DoneExclusiveMode Direct3D9: (WARN) :No SW device has been registered. GetAdapterCaps fails. D3D9 Helper: IDirect3D9::GetDeviceCaps failed: D3DERR_NOTAVAILABLE Direct3D9: (INFO) :======================= Reference HWVP device selected Direct3D9: (INFO) :HalDevice Driver Style 9 Direct3D9: :DoneExclusiveMode Direct3D9: (INFO) :======================= Hal HWVP device selected Direct3D9: (INFO) :HalDevice Driver Style 9 Direct3D9: :DoneExclusiveMode D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 1.58456e+029f. This is ok. D3DX: Unicode support: 1 'StateManager.exe': Loaded 'C:\WINDOWS\system32\usp10.dll', Cannot find or open the PDB file D3DX: (INFO) Using SSE2 optimizations Miss rate before optimization: 1.000000 Miss rate after optimization: 1.000000 'StateManager.exe': Loaded 'C:\WINDOWS\system32\D3DCompiler_43.dll', Cannot find or open the PDB file 'StateManager.exe': Unloaded 'C:\WINDOWS\system32\D3DCompiler_43.dll' Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 13 Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 14 Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 25 //... lots more lines like these [/code] [/quote] Bump! Any ideas as to what I should try in order to solve these warnings? Or there is no way?
  15. Well, I have just ran the StateManager sample app, and it gave a lot of SetRedundantState warnings... So I'm at a loss now. Perhaps it has to do with my GPU? It's an NVIDIA GeForce 8400 GS, and Direct3D9 seems to recognize it successfully (this is from the StateManager sample run): Edit: I forgot to mention that I'm using the June 2010 DirectX SDK [code] Direct3D9: :====> ENTER: DLLMAIN(010ee6e0): Process Attach: 00000c8c, tid=00001694 Direct3D9: :====> EXIT: DLLMAIN(010ee6e0): Process Attach: 00000c8c Direct3D9: (INFO) :Direct3D9 Debug Runtime selected. Direct3D9: (WARN) :No SW device has been registered. GetAdapterCaps fails. D3D9 Helper: IDirect3D9::GetDeviceCaps failed: D3DERR_NOTAVAILABLE 'StateManager.exe': Loaded 'C:\WINDOWS\system32\d3dref9.dll', Cannot find or open the PDB file Direct3D9: (INFO) :======================= Reference HWVP device selected Direct3D9: (INFO) :HalDevice Driver Style 9 Direct3D9: :DoneExclusiveMode Direct3D9: (WARN) :No SW device has been registered. GetAdapterCaps fails. D3D9 Helper: IDirect3D9::GetDeviceCaps failed: D3DERR_NOTAVAILABLE Direct3D9: (INFO) :======================= Reference HWVP device selected Direct3D9: (INFO) :HalDevice Driver Style 9 Direct3D9: :DoneExclusiveMode Direct3D9: (INFO) :======================= Hal HWVP device selected Direct3D9: (INFO) :HalDevice Driver Style 9 Direct3D9: :DoneExclusiveMode D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 1.58456e+029f. This is ok. D3DX: Unicode support: 1 'StateManager.exe': Loaded 'C:\WINDOWS\system32\usp10.dll', Cannot find or open the PDB file D3DX: (INFO) Using SSE2 optimizations Miss rate before optimization: 1.000000 Miss rate after optimization: 1.000000 'StateManager.exe': Loaded 'C:\WINDOWS\system32\D3DCompiler_43.dll', Cannot find or open the PDB file 'StateManager.exe': Unloaded 'C:\WINDOWS\system32\D3DCompiler_43.dll' Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 13 Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 14 Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 25 //... lots more lines like these [/code]