Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Direct3D Not working outside project?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
13 replies to this topic

#1 rukiruki   Members   -  Reputation: 161

Like
0Likes
Like

Posted 20 February 2013 - 12:25 PM

Hi. Using DirectX9.... We have a 2D game called 9th Dawn which used DirectxSprite for rendering. We recently switched it to Direct3D rendering using D3DPT_TRIANGLELIST. This works fine when running directly from Visual Studio~ however when I take the generated .exe and try running it, I get triangle artifacts instead of textures. I have tried the .exe in an isolated folder with the exact same .dlls and data (includes textures) as the visual studio build, and also tried running the .exe in the exact same folder as Visual Studio project so it uses the same data.

 

Title screen comparrison:

https://dl.dropbox.com/u/15579799/dxscreens/title1.png

https://dl.dropbox.com/u/15579799/dxscreens/title2.png

 

In game comparrison:

https://dl.dropbox.com/u/15579799/dxscreens/game1.png

https://dl.dropbox.com/u/15579799/dxscreens/game2.png

 

I have no idea what's going on. I tried the release build on another computer and I got the triangle artifacts. I sent it to a friend in USA and he actually saw the correct textures.

It looks like the textures are definitely getting loaded because their colours seem correctish, it just seems to be only using the first pixel in the texture. I load textures from a DAT file buffer using D3DXCreateTextureFromFileInMemoryEx(...). I have a radeon 7950 graphics card

 

Could it be I need to set a render state?


Edited by rukiruki, 20 February 2013 - 12:33 PM.


Sponsor:

#2 Seabolt   Members   -  Reputation: 633

Like
0Likes
Like

Posted 20 February 2013 - 01:56 PM

This could happen for a lot of reasons. Are you able to see it work in release when deployed from VS?


Perception is when one imagination clashes with another

#3 rukiruki   Members   -  Reputation: 161

Like
0Likes
Like

Posted 20 February 2013 - 02:44 PM

This could happen for a lot of reasons. Are you able to see it work in release when deployed from VS?

Hi Seabolt thanks for your reply. I'm only building in Release mode, which works fine if ran from VS, but the .exe it generates to the Release folder has the problem. Is that what you meant?



#4 Seabolt   Members   -  Reputation: 633

Like
0Likes
Like

Posted 20 February 2013 - 03:32 PM

Ah alright. Have you tried running the exe generated in the Release folder of your solution? Does that work? Also are you error checking your asset loads?


Perception is when one imagination clashes with another

#5 rukiruki   Members   -  Reputation: 161

Like
0Likes
Like

Posted 20 February 2013 - 03:41 PM

Hi Seabolt, yes I have tried running the .exe in the Release folder (no assets get loaded, no fonts or textures). I have tried running it in an isolated folder with identical assets, and the main project folder which uses the exact same assets as the VS-ran build. I get the same behaviour all the time, the .exe never renders textures properly.

 

I do error check my texture loads, they are being found in the DAT buffer and loaded fine. I don't understand how it can be any different than running it in VS :/



#6 Seabolt   Members   -  Reputation: 633

Like
0Likes
Like

Posted 20 February 2013 - 04:11 PM

Are you using absolute paths to your assets? Try taking the exe and moving it into various folders and seeing if it will work at all.


Perception is when one imagination clashes with another

#7 rukiruki   Members   -  Reputation: 161

Like
0Likes
Like

Posted 20 February 2013 - 05:25 PM

I'm using relative paths to the DAT folder, ie. "data\\datfile", the .exe does find it and load from that file correctly (along with sound effects which work). I've tried it in all possible folders

 

thanks



#8 Jason Z   Crossbones+   -  Reputation: 5163

Like
1Likes
Like

Posted 20 February 2013 - 09:56 PM

Have you tried using PIX to check what is going on in your scene rendering?  It would seem that the textures aren't properly loaded for some reason - what are you using to load the textures?  Are you sure that all of the runtime dependencies are installed on the machine that you are testing on?

 

When you take a frame grab in PIX, examine the textures that are being bound and make sure they are loaded properly - I would bet that this is the source of the issue.



#9 rukiruki   Members   -  Reputation: 161

Like
0Likes
Like

Posted 21 February 2013 - 04:25 PM

Hi Jason, thanks for you reply. I'm loading textures from a DAT file, using my own error checking I can see that the DAT file IS found and textures are loaded from it. This is the function:
https://dl.dropbox.com/u/15579799/dxscreens/loadtext.JPG

 

I have new information on this issue. I loaded up my newest engine which has some simple d3d render calls, again in 2D. It works from the IDE in debug mode, but NOT in release mode. The generated .exe from the debug mode WORKS, but the generated .exe from the release mode doesn't work. After some googling I found out it was the /MDd to /MD flag in Project Properties->c++->code generation, as outlined in this post:

http://stackoverflow.com/questions/10526566/directx-release-build-works-through-vs2010-but-not-exe

 

On further reading it may be due to some directx things not being initialised in Release mode, where they are automatically initialised in debug mode, but I have no idea what that could be, even after cross referencing with a few directx tutorials~ I can't see anything I may have missed.


Here are some pics of the current issue regarding debug and release mode:
https://dl.dropbox.com/u/15579799/dxscreens/c1.jpg
https://dl.dropbox.com/u/15579799/dxscreens/c2.jpg

 

The problems ONLY occur with textured triangle lists. The NULL textured triangle lists (such as the white rectangle in the background) are fine. In this engine, fonts are rendered using textured triangle lists.

Thanks for suggesting PIX, I never used it before but it provided some cool information, but nothing that I could work out why the error was happening. If we isolate to the first rendered triangle list, the left 'panel' graphic, pix shows this as the current rendered image:
https://dl.dropbox.com/u/15579799/dxscreens/pix1.jpg

It shows the following location and UV coorindates, which I have checked match up with the screen dimensions and texture:
https://dl.dropbox.com/u/15579799/dxscreens/pix2.jpg

And this is the texture it is setting, showing correctly in PIX, which I assume means it loaded correctly:
https://dl.dropbox.com/u/15579799/dxscreens/pix3.jpg

So, I've learned a lot, but still no idea how on earth to fix this, I must be missing something...
I can confirm that the release build in IDE DOES WORK if I set /MDd flag, and the generated .exe also WORKS with that flag set. When changed to /MD neither work.

 

Any tips? Have I missed a step in the frame calls?
 



#10 Jason Z   Crossbones+   -  Reputation: 5163

Like
2Likes
Like

Posted 21 February 2013 - 07:00 PM

Can you show a screen shot of the PIX mesh window for 'Pre-' and 'Post-' vertex shader?  It looks like one of the two triangles is being culled, and it would be helpful to see what w-values those triangles have before heading into the rasterizer (the xyz would be interesting too).

 

One other thing to try is to use the reference device and generate a PIX frame grab from that with a debug build and a release build to see if anything is different between the two, as well as to find out if it properly renders the scene.  If you aren't getting any errors, and you get totally different results between debug and release builds, then it could potentially be something with your driver (have you updated recently?).



#11 rukiruki   Members   -  Reputation: 161

Like
0Likes
Like

Posted 21 February 2013 - 08:12 PM

Can you show a screen shot of the PIX mesh window for 'Pre-' and 'Post-' vertex shader?  It looks like one of the two triangles is being culled, and it would be helpful to see what w-values those triangles have before heading into the rasterizer (the xyz would be interesting too).

 

One other thing to try is to use the reference device and generate a PIX frame grab from that with a debug build and a release build to see if anything is different between the two, as well as to find out if it properly renders the scene.  If you aren't getting any errors, and you get totally different results between debug and release builds, then it could potentially be something with your driver (have you updated recently?).


Jason, do you mean this?
https://dl.dropbox.com/u/15579799/dxscreens/pix2.jpg

It says post vertex shading disabled. I'm going to try a working version in PIX now



#12 rukiruki   Members   -  Reputation: 161

Like
0Likes
Like

Posted 21 February 2013 - 08:34 PM

I ran the working build in PIX and grabbed two screenshots.

https://dl.dropbox.com/u/15579799/dxscreens/working_pix1.jpg

https://dl.dropbox.com/u/15579799/dxscreens/working_pix2.jpg

 

I'm not familiar with PIX but I can't really spot any differences between the builds. *edit* err, actually- on the working build, what on earth is that 4th position value (-4310602xxxx)? I grabbed my graphics card's latest drivers yesterday. it didn't work on my friends PC (ATI gfx card) but the error does not occur on my other friend's PC (nvidia).

There is a possibility that im rendering the triangle list in the wrong order. I render a rectangle in this order:

// 0 - bottom left
// 1 - top left
// 2 - top right

 

// 3 - bottom left
// 4 - top right
// 5 - bottom right

I did have backface culling disabled
// Disable backfaces
d3ddev->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);

I switched to
// Disable backfaces
    d3ddev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);

But noticed no difference. Thanks Jason for your help


Edited by rukiruki, 21 February 2013 - 08:38 PM.


#13 rukiruki   Members   -  Reputation: 161

Like
1Likes
Like

Posted 21 February 2013 - 08:43 PM

OH WOW. It was the rhw value. It's never set for any vertices. I set every vertex rhw value to 1.0 and now it's working in every build.

Thank you so much Jason, if you didn't suggest PIX and comparing the two I never would have spotted this. I'm not sure how the reputation thing works but I tried to add some rep for you. Thanks again, I think it's fully solved now



#14 Jason Z   Crossbones+   -  Reputation: 5163

Like
2Likes
Like

Posted 21 February 2013 - 08:55 PM

Great - I'm glad that its all cleared up now.  I have seen it a few times before where if the w value isn't correct then you can get flaky partially culled geometry, so it is a good place to start looking when you see those symptoms.  I still think it is strange that there was a difference between debug and release, but if its fixed, then its fixed!  Thanks for the reputation bump too :)






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS