Jump to content
  • Advertisement

HeroOfSpielburg

Member
  • Content Count

    9
  • Joined

  • Last visited

Community Reputation

122 Neutral

About HeroOfSpielburg

  • Rank
    Newbie
  1. HeroOfSpielburg

    VertexShader consts for instancing

    You're right, this will provide optimal throughput without requiring much change to my shader. Thanks for the insight, I was buried in the details. :) The only downside is when/if either of the data parameters needed in the parent or child struct changes to a different number of register lines, things start to get a little tricky, at which point I'll probably have to move to just a general "I have a very large array of float4s" and further generalize the structure element names. Thank you again.
  2. Hello, I'm writing something similar to a particle engine, where I have a bunch of quads in a vertex buffer, and modify each quad via two transform structures, child and parent, in the vertex shader. struct SpriteParent { float4 mtxParentRS; // Parent sprite rot/scl float4 fParentPosAlpha; // Parent position and alpha }; struct SpriteChild { float4 mtxChildRS; // Child primitve rot/scl float4 fTextureUVAlpha; // UV offset (pattern) and alpha }; So I can reference them easily in HLSL, I define a couple of arrays in the shader file as well. SpriteParent g_SpriteParents[30]; SpriteChild g_SpriteChildren[90]; The number of "child" primitives per "parent" sprite is variable, so the ratio of SpriteParent to SpriteChild structures that I actually use changes per DrawIndexedPrimitive call. Although I define 90 children in the shader, I may not use them all, or may actually need more if the ratio of Children:Parent is quite high. I keep track of which structures to reference for each quad primtive via blend indicies in the vertex data, and upload batches of the SpriteParent and SpriteChild structures via ID3DXConstantTable::SetFloatArray. The problem is I run into trouble when I need to access more Parent or Child structures than I define as above in the shader file; I get a D3D error telling me that the handle to the structure element is not defined. If I define the structure arrays to have the maximum possible amount utilized in any configuration, the collective size is larger than can fit in constant register memory, and the shader doesn't compile. Is there a way to manage the allocation of these structures in the shader more dynamically so I can get the optimal packing I'm calculating on the game engine side? Or do I have to abandon user-defined structures then and write my shader in terms of pure constant registers and address offsets? (Never done this before, a little leery.) Thank you for the advice!
  3. Hello, A while ago I made a post about trouble I was having using the Debug Version of D3D9. Essentially if I enabled it through the D3D control panel, any call to Direct3DCreate9 would fail (even the ones in the SDK samples). I fought with it for months, but never could figure out why. http://www.gamedev.net/community/forums/topic.asp?topic_id=454956&forum_id=10&gforum_id=0 Anyway, the post is retired now, but in case anyone else has this same mind-boggling behavior, I finally have it working on my PC. All it took was a complete reinstall of VisualStudio and all of my SDKs (DirectX, .NET Framework, etc.). I wish there was a better way, but if you're out of luck and really need the Debug version of D3D, this is a way to go apparently. Best,
  4. HeroOfSpielburg

    Packing VS structs

    Hello, This topic has been skirted around several times before in other threads, but unfortunately I haven't been able to construct a solution yet, so I'll present my particular challenge here. I am trying to build a singular instancing solution that will work on any sort of hardware. I do not want to incur the CPU overhead of vertex buffer locking so I am using an extremely simplistic vertex stream and loading the vertex shader constant registers with a series of "instance" structures. Currently, I handle one instance's attributes per five register lines (20 floats), but I'd like to get that down to three lines. A lot of the data for the instance is quite simple and a waste at a full float (for example one attribute is a bias to apply to the vertex position that is either 0, 0.5, or -0.5). One big win I thought of trying is using HALF values for things like matrices and texture UVs. However, I've read that this is not supported on all hardware, and in the case it is not it is "emulated as a float". What does this emulation produce, exactly? Can I still upload a 16-bit floating value in the struct and have the shader reference it correctly? I tried something similar by cramming an RGBA value into a single 32-bit int and pulling out the component values via recursive division, but when I looked at the results in PIX, it seemed that the shader program wouldn't correctly utilize the contents of the register, the values weren't listed in the debugger. If there is a better way to go about uploading compact limited precision data to a vertex shader, I would be much obliged to hear some ideas. Thank you for the time!
  5. Hello. I'm working on a font renderer, and currently trying to get rendering to a texture working. Each letter uses glyph metrics to build UV data, I look up the glyphs from a font texture, two triangles per letter. I create an appropriately-sized A8R8G8B8 texture (like 96x32), designate the usage as D3DUSAGE_RENDERTARGET, and set surface level 0 as my render target. Then I draw the triangles, leveraging the font texture to create the word. Nothing special. However, I'm currently at the point where the polygons are making it in the VIEWPORT thumbnail in PIX, but after that, I can't tell what's happening. If I try "Debug This Pixel" on any number of elements in the render target preview, all I get is the Clear operation showing up in the pixel history. Does this mean the pixels are failing some test after the VIEWPORT stage but before PIXEL SHADER in the pipeline? How can I figure out what I'm missing here? Everything I can think of is dumbed down: ALPHATEST, off CULLMODE, none FILLMODE, solid ZENABLE, false STENCILENABLE, false The font texture is set ok, I can see it in the sampler. The DrawIndexedPrimitiveUP, SetPixelShader/VertexShader/Declaration all return S_OK...everything looks kosher. If anyone can give me a hint as to what I'm missing, or how I can use PIX (08/2007) more effectively, I'd be much obliged.
  6. Thanks for the help! I've set up VisualStudio to use the Windows Symbol Server. I've also extremely slimmed down the problem-space in noticing that the same crash happens with the CreateDevice sample from the DirectX SDK. ^^;; So I guess this isn't a managed problem, just a DirectX problem in general on my system. Now, as before, I get Windows breakpoint triggered inside of Direct3DCreate9... if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) ) I can't step in here, that triggers the breakpoint. Here is the callstack with additional symbols loaded... ntdll.dll!_DbgBreakPoint@0() d3d9d.dll!00beed3d() [Frames below may be incorrect and/or missing, no symbols loaded for d3d9d.dll] d3d9d.dll!00bee4cb() d3d9d.dll!00bee59b() ntdll.dll!_ZwClose@4() + 0xc bytes advapi32.dll!_BaseRegCloseKeyInternal@4() + 0x49 bytes d3d9d.dll!00be2db4() ntdll.dll!_RtlImageDirectoryEntryToData@16() + 0x3f bytes ntdll.dll!_LdrpGetProcedureAddress@20() + 0xe7 bytes ntdll.dll!_LdrGetProcedureAddress@16() + 0x18 bytes kernel32.dll!_GetProcAddress@8() + 0x3e bytes 0012fdc0() ntdll.dll!_RtlpImageNtHeader@4() + 0x4a bytes user32.dll!__CreateWindowEx@52() + 0xb1 bytes user32.dll!_CreateWindowExW@48() + 0x33 bytes > CreateDevice.exe!wWinMain(HINSTANCE__ * hInst=0x00400000, HINSTANCE__ * __formal=0x00000000, HINSTANCE__ * __formal=0x00000000, HINSTANCE__ * __formal=0x00000000) Line 155 + 0x2f bytes C++ CreateDevice.exe!__tmainCRTStartup() Line 324 + 0x35 bytes C CreateDevice.exe!wWinMainCRTStartup() Line 196 C kernel32.dll!_BaseProcessStart@4() + 0x23 bytes Since this seems to be a problem with creating the Api itself, I don't think it's a HAL versus REF problem, I'm not even getting to the device creation, the actual API can't initialize. What's strange though is that if I put a breakpoint right before the Direct3DCreate9 function, I get there ok and the call stack looks all right, but when I try to get past that function, the call stack seems to change and the above call stack is displayed as a result... as if I failed on CreateWindowEx, which I already cleared previously... does this mean the stack was corrupted during the D3D initialization?? Again, the output window is sparse in terms of debug messages... 'CreateDevice.exe': Loaded 'D:\CreateDevice\Debug\CreateDevice.exe', Symbols loaded. 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', Symbols loaded (source information stripped). 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', Symbols loaded (source information stripped). 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\d3d9.dll', Symbols loaded (source information stripped). 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\d3d8thk.dll', Symbols loaded (source information stripped). 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', Symbols loaded (source information stripped). 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\user32.dll', Symbols loaded (source information stripped). 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', Symbols loaded (source information stripped). 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', Symbols loaded (source information stripped). 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', Symbols loaded (source information stripped). 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\version.dll', Symbols loaded (source information stripped). 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\winmm.dll', Symbols loaded (source information stripped). 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\imm32.dll', Symbols loaded (source information stripped). 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\lpk.dll', Symbols loaded (source information stripped). 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\usp10.dll', Symbols loaded (source information stripped). 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\MSCTF.dll', Symbols loaded (source information stripped). 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\MSCTFIME.IME', Symbols loaded (source information stripped). 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\ole32.dll', Symbols loaded (source information stripped). 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\IMJP9.IME', No symbols loaded. 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\shell32.dll', Symbols loaded (source information stripped). 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', Symbols loaded (source information stripped). 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\IMJP9K.DLL', No symbols loaded. 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll', Symbols loaded (source information stripped). 'CreateDevice.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2982_x-ww_ac3f9c03\comctl32.dll', Symbols loaded (source information stripped). 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\uxtheme.dll', Symbols loaded (source information stripped). 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\d3d9d.dll', No symbols loaded. 'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\d3dx9d_33.dll', No symbols loaded. Direct3D9: :====> ENTER: DLLMAIN(00bee6e0): Process Attach: 00000e94, tid=00000764 Direct3D9: :====> EXIT: DLLMAIN(00bee6e0): Process Attach: 00000e94 Direct3D9: (INFO) :Direct3D9 Debug Runtime selected. Windows has triggered a breakpoint in CreateDevice.exe. This may be due to a corruption of the heap, and indicates a bug in CreateDevice.exe or any of the DLLs it has loaded. To confirm, my Debug Output level for D3D is all the way right at "More", and I've selected "Use Debug Version of Direct3D 9", "Maximum Validation", "Enable Shader Debugging", "Break on D3D9 Error", "Enable Hardware Acceleration". However, toggling all of these checkboxes off and on has no effect. Should I repost this over in a more general D3D forum, perhaps? : Thanks for the help!!
  7. Thanks for the suggestions!~ I will check unmanaged debugging in my project. As for the setup of D3D, it normally happens after the form is set up and what not, but as a test I thought that putting it at the top of my application and seeing it fail there would be a lot more stable test. Your question does give me some ideas though; I'll next just try making a .net app from scratch with the wizard and throw in the Direct3DCreate9 there, so it's as native as environment as possible, and see if I get the same behavior. Thanks for now, I appreciate it!
  8. Thank you for the reply. My network's been down for a couple days, sorry for the delay. The break happens right on the line where I call Direct3DCreate9, but the call stack is much deeper... ntdll.dll!7c941230() [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] d3d9d.dll!0f3fed3d() d3d9d.dll!0f3fe4cb() d3d9d.dll!0f3fe59b() ntdll.dll!7c94d592() advapi32.dll!77d86bcc() d3d9d.dll!0f3fe440() d3d9d.dll!0f3f2db4() ntdll.dll!7c950895() ntdll.dll!7c959a9c() ntdll.dll!7c959b3f() ntdll.dll!7c959aeb() kernel32.dll!7c80e3dc() kernel32.dll!7c801be6() kernel32.dll!7c801bf6() ntdll.dll!7c959aeb() ntdll.dll!7c959ba0() kernel32.dll!7c80adde() kernel32.dll!7c80adf0() d3d9.dll!4b68af2e() ntdll.dll!7c959b3f() ntdll.dll!7c959aeb() ntdll.dll!7c959b3f() ntdll.dll!7c959aeb() ntdll.dll!7c959d27() > GameD.exe!Form::InitEditForm(gcroot<Form::EditForm ^> GameForm={...}, HWND__ * hWnd=0x0002086a, const char * const pstrRoot=0x001f17c0) Line 441 C++ [Managed to Native Transition] GameD.exe!Form::EditForm::EditForm() Line 78 C++ Does this make any sense?
  9. Hello everyone, This hasn't always been the case, but recently something has happened to prevent me from using the Debug version of Direct3D 9. Initially I had the problem with the April 2007 SDK, but now I'm on June 2007 SDK and still having the same problem. If I set the version to Retail in the DX Control Panel, things run fine, but set it to Debug and I tank at my call to Direct3DCreate9(D3D_SDK_VERSION), even if it's the first line in my program. Normally I would expect this to return NULL if it wasn't going to work, not cause an exception somewhere inside. The dialog box that appears displays: "Windows has triggered a breakpoint in GameD.exe. This may be due to a corruption of the heap, and indicates a bug in GameD.exe or any of the DLLs it has loaded. The output window may have more diagnostic information." There's nothing fishy in my output pane (aside from the usual dozens of DLL loads including d3dx9_34.dll). It ends with... Direct3D9: :====> ENTER: DLLMAIN(0f49e6e0): Process Attach: 00000260, tid=00000d64 Direct3D9: :====> EXIT: DLLMAIN(0f49e6e0): Process Attach: 00000260 Direct3D9: (INFO) :Direct3D9 Debug Runtime selected. Windows has triggered a breakpoint in GameD.exe. This may be due to a corruption of the heap, and indicates a bug in GameD.exe or any of the DLLs it has loaded. And here's the front end of text from PIX on the same error... PIX Logfile created at: 18:29:26 Frame 000001 ....PRE: Frame(1) Trigger 'Program Start' fired Frame 000001 ........PRE: Direct3DCreate9(32) Direct3D9: :====> ENTER: DLLMAIN(1221e6e0): Process Attach: 0000068c, tid=00000890 Direct3D9: :====> EXIT: DLLMAIN(1221e6e0): Process Attach: 0000068c Direct3D9: (INFO) :Direct3D9 Debug Runtime selected. An unhandled exception occurred. Frame 000001 ............PRE: CreateProcessW(0x0012CE30, 0x001F9C18, <unknown type 182>, <unknown type 182>, TRUE, 0x00000000, NULL, NULL, <unknown type 184>, <unknown type 185>) Frame 000001 ............POST: <TRUE> CreateProcessW(0x0012CE30, 0x001F9C18, <unknown type 182>, <unknown type 182>, TRUE, 0x00000000, NULL, NULL, <unknown type 184>, <unknown type 185>) Direct3D9: :====> ENTER: DLLMAIN(1221e6e0): Process Detach 0000068c, tid=00000890 I've looked around on the boards and haven't found anything yet. Unfortunately, not being able to run the Debug version is preventing me from debugging a lot of other problems. If it's relevant I'm using a GeForce 6600. If anyone has an idea as to why this is happening, I'd be much obliged. Thanks.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!