Sign in to follow this  

D3DERR_INVALIDCALL when creating texture

This topic is 3147 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I started to work with HLSL and when I got to make it able to render textures I noticed I can't load a the textures. I haven't changed anything in the code to load and store the texture, at all. I even have an old version saved and used that but it didn't work. I get D3DERR_INVALIDCALL when using: D3DXCreateTextureFromFileA(pD3DDev, tempMaterials[i].pTextureFilename, &texture[i]) texture is defined as: texture = new LPDIRECT3DTEXTURE9[matCount]; with matCount being the correct number. pD3DDev = LPDIRECT3DDEVICE9 pD3DDev; tempMaterials = D3DXMATERIAL* tempMaterials = (D3DXMATERIAL*)tempBufMaterial->GetBufferPointer(); Where tempBufMaterial is created from a successful D3DXLoadMeshFromX(); I am absolutely clueless, the .bmp files are in the right places too, I can open the mesh with dxviewer and the textures work.

Share this post


Link to post
Share on other sites
Quote:
Original post by Hannesnisula
tempMaterials[i].pTextureFilename is "bihull.bmp" which is the correct name.
And that file exists on the current path? I.e. in the same directory as the mesh?
And you're sure that the error is coming from that function (Put a breakpoint on it and step over it)?

Share this post


Link to post
Share on other sites
Yes the error is comming from that function. And strangely enough, yes they're in the same folder. If some "default" folder or w/e is set in my project (which I don't know about) it should work anyway because my mesh and pictures are in the same folders everywhere I've got a version of it.

EDIT: I tried with another mesh + texture and that worked. I'm still very confused why the other didn't work, it works with earlier versions of my program.

Share this post


Link to post
Share on other sites
Yes DXViewer can open my mesh with textures and everything. All I've changed is that I've added HLSL and removed the SetRenderState functions and changed SetTransform to the effect's SetMatrix function.

I've never used the debug function in VS2008 before so now I noticed I get:

Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 29
And it's a lot more numbers than 29. I've searched and found some that say it's because I don't use a "pure" device (which I don't know what that is). Does it decrease the performance of the program?

Also, I get some error each time I shut down the program:

Debug Assertion Failed!
...
_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)

and then the debug says:

Direct3D9: (ERROR) :GetClientRect Failed ?
Direct3D9: (ERROR) :GetClientRect Failed ?
Direct3D9: (ERROR) :BitBlt or StretchBlt failed in Present

Since other meshes (which has textures) is being rendered in my program I am pretty sure I've somehow messed something up (even though the mesh + textures that don't work are in the same folder + DXViewer can render it without any problem) so I guess I'd better fix these other problems.

EDIT: My Present function looks like this:
pD3DDev->Present(0, 0, 0, 0);

Which has been left unchanged for ages.

Share this post


Link to post
Share on other sites
Quote:
Original post by Hannesnisula
I've never used the debug function in VS2008 before so now I noticed I get:

Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 29
And it's a lot more numbers than 29. I've searched and found some that say it's because I don't use a "pure" device (which I don't know what that is). Does it decrease the performance of the program?
It just means that you're calling SetRenderState() with a state that's already set, so it's a redundant change. If you have a pure device then it's more expensive, but if you don't have a pure device, D3D will filter redundant changes for you.
A pure device is a device created with the D3DCREATE_PUREDEVICE flag. From the Documentation:
Specifies that Direct3D does not support Get* calls for anything that can be stored in state blocks. It also tells Direct3D not to provide any emulation services for vertex processing. This means that if the device does not support vertex processing, then the application can use only post-transformed vertices.
There's also a bit in the FAQ under "What is the purpose of the D3DCREATE_PUREDEVICE flag?".

Quote:
Original post by Hannesnisula
Also, I get some error each time I shut down the program:

Debug Assertion Failed!
...
_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
You have some heap corruption going on, usually caused by deleting a pointer twice, or using a pointer after it's been deleted. That's not D3D related, it refers to one of your new[]'d pointers.

Quote:
Original post by Hannesnisula
Direct3D9: (ERROR) :GetClientRect Failed ?
Direct3D9: (ERROR) :GetClientRect Failed ?
Direct3D9: (ERROR) :BitBlt or StretchBlt failed in Present
That's usually caused by killing your window before D3D - D3D is still trying to render, but the window has been destroyed. Check that you're not destroying your window (Processing WM_DESTROY) while D3D is still active.

Share this post


Link to post
Share on other sites
Thank you so much! Evil Steve for president :D

EDIT: Forgot to ask something >.< I don't use the D3D Device's SetRenderState() but I do set mipfilter etc in my sampler in my HLSL shader. Could that cause the problem? Then how can I change the render state to anything else without doing redundant changes?

Share this post


Link to post
Share on other sites
Quote:
Original post by Hannesnisula
Thank you so much! Evil Steve for president :D

EDIT: Forgot to ask something >.< I don't use the D3D Device's SetRenderState() but I do set mipfilter etc in my sampler in my HLSL shader. Could that cause the problem? Then how can I change the render state to anything else without doing redundant changes?
I gather that the effects framework makes a lot of redundant state changes. Short of changing to a different system I don't think there's much you can do.
It's not really much of a problem to be honest, if it annoys you too much, just turn the debug output level down a notch [smile]

Share this post


Link to post
Share on other sites
Quote:
Original post by Hannesnisula
Oh, I just thought it was a huge performance decrease. So if you're using HLSL with samplers that set states, you're worse off with a pure device, right?
Probably, but it'll be a very small performance drop. If you're worried about it, try profiling with and without a pure device and see if there's any difference.

Share this post


Link to post
Share on other sites

This topic is 3147 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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