7 Replies - 1288 Views - Last Post: 29 July 2013 - 08:08 AM

#1 rex64  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 168
  • Joined: 31-January 12

DirectX Errors

Posted 25 July 2013 - 10:50 AM

We are getting a few DirectX errors (in DebugView) and are not sure the best way to handle them. No line number is specified. What do you recommend?

[5512] Direct3D9: (ERROR) :Cannot render when currently set textures are locked. 
[3304] Direct3D9: (WARN) :Ignoring redundant SetRenderState - 8 
[3304] Direct3D9: (WARN) :Ignoring redundant SetSamplerState. Sampler: 0, State: 1 


Is This A Good Question/Topic? 0
  • +

Replies To: DirectX Errors

#2 BBeck  Icon User is online

  • Here to help.
  • member icon


Reputation: 560
  • View blog
  • Posts: 1,263
  • Joined: 24-April 12

Re: DirectX Errors

Posted 25 July 2013 - 01:51 PM

You're getting DX errors in XNA!?!?
Was This Post Helpful? 0
  • +
  • -

#3 rex64  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 168
  • Joined: 31-January 12

Re: DirectX Errors

Posted 25 July 2013 - 03:38 PM

I am using the DebugView and the DirectX control panel to view the underlying DirectX errors because XNA is not passing the errors on very well.
Was This Post Helpful? 0
  • +
  • -

#4 BBeck  Icon User is online

  • Here to help.
  • member icon


Reputation: 560
  • View blog
  • Posts: 1,263
  • Joined: 24-April 12

Re: DirectX Errors

Posted 26 July 2013 - 07:02 AM

Sounds like you are calling something in a very wrong way. What errors are you getting in XNA? And what did you change that caused this error?

This post has been edited by BBeck: 26 July 2013 - 07:04 AM

Was This Post Helpful? 0
  • +
  • -

#5 rex64  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 168
  • Joined: 31-January 12

Re: DirectX Errors

Posted 27 July 2013 - 11:34 AM

These errors happen when we are running without debug mode. They do not seem to happen in debug mode.

View PostBBeck, on 26 July 2013 - 02:02 PM, said:

Sounds like you are calling something in a very wrong way. What errors are you getting in XNA? And what did you change that caused this error?

Was This Post Helpful? 0
  • +
  • -

#6 BBeck  Icon User is online

  • Here to help.
  • member icon


Reputation: 560
  • View blog
  • Posts: 1,263
  • Joined: 24-April 12

Re: DirectX Errors

Posted 28 July 2013 - 08:29 AM

What do you mean that you only see it without debug mode? Do you mean that you only see it in the Release version and not the Debug version? (Does XNA/C# even have those two versions, or am I thinking C++? I've been jumping back and forth a lot lately.) Or do you mean that you the problem goes away when you start stepping through it in the debugger?

In situations where you cannot use the debugger, generally the strategy that you employ is to set "flags" in the code.

First, go back to a previous build that WAS working and figure out what you are changing that is causing it to fail. If you have good version control, this should not be too difficult. But, assuming that that's not an option because you don't have good version control, you can set flags.

You have to pinpoint which line of code is causing the problem. I know that can be easier said than done in a large game project. But you still need to try and pinpoint the line of code causing the problem.

When you cannot just simply step through the code in the debugger to do that, you need to use "flags". What I mean is that you write additional code to tell you what you cannot see. For example, you could write code to put a message box on the screen or send output to a console window to tell you "This section of the code has been reached." Once you know that a section of the code has been reached without a problem, you can move the flag forward. Generally, I would use two flags. One before the problem and one after the problem. The one after the problem, I would place to a spot where I feel the code is not reaching and then keep trying to move it back closer and closer to the spot where the problem is occurring.

By employing flags before and after the problem and moving them closer and closer together, you can generally move them so close to the problem that they reveal which line of code is causing the problem.

Now with game programming, and XNA specifically, you may get to the point where you need to go inside of XNA itself to see the problem and you simply can't. Then you may have to use other strategies.



As to your specific errors, I think I have a very vague idea of what it is complaining about, but my knowledge of DX is still at the beginner level and it will probably be months, or even a year (on my current learning path as I am studying DX11 now) before I really know what that DX error means and how to solve it.

Generally, in DX the graphics pipeline has assets that are "attached" to it and others that are sent through it. Without all the tech jargon: you send vertices and indices to the graphics card to be processed for drawing. There are certain "assets" (or buffers in actuality) that you attach to the process for the process to use. One such buffer is a texture buffer (there is a specific name that they use for these buffers but I can't recall it off the top of my head at the moment. I want to say "resources" but I can't remember. I could look it up if you think it's helpful.)

So, you send the vertices and indices through the graphics card (pipeline) and buffers, such as textures are attached. Most likely, the graphics card is going to use that attached buffer to shade the triangles that it is drawing with the vertices and indices. But those buffers can be attached with different status when you attach them. Off the top of my head, I would say they are "read-only" or "read-write". So there is some "locking" that occurs with these buffers. I read about this a few weeks ago. I want to say that there were at least 6 possible statuses/ways you could set the buffers. These buffers are very generic in DX. They can be used for almost anything. So, when you define their status, you really are setting rules for the graphics card on how, or how not, it is allowed to use the buffer. In XNA, we think of it as a "texture" "buffer", but in reality it is just a buffer that has its status set to be used in a sort of "texture" like manner. To DX it's just a buffer full of data. That's why you have to set rules around how DX is allowed to use it. I went through an example recently where the world matrix was passed in a buffer roughly the same way. You can literally send anything to the graphics card in these buffers. They are highly generic. A texture buffer is mostly a texture buffer just because of the "rules" defined around how it can be used. That's where you get into locking issues like the one that it is so un-happy about. It's trying to do something that is against the rules. Or more accurately, you are telling it to do something that's against the rules. So, either the rules need to be changed, or you need to stop telling it to do something that's against the rules. At least, that's my take on this.

Hearing that the "current texture is locked" makes me think you either have a multi-threaded problem or that the texture buffer is defined wrong for what you are attempting to do in terms of whether it is read-only or read-write or such. I think you need a DirectX expert to figure that one out. But really, you should be seeing XNA errors somewhere. If you're not getting XNA errors, from XNA, I would think you are doing something radically wrong.

I would probably not ignore those warnings (even though I often ignore warnings). They may be giving you the clue to solve the problem. The redundant render state sounds like something was setup wrong too.

Are you using a HLSL shader here? Is that why you're not getting any feedback from XNA? Do you have a bad shader? It's complaining about the Sampler you setup.

I would review all the sampler's setup, both in XNA and also inside of any custom shaders you have. I would try and find the redundancy that its complaining about. I would also look at my rasterization states.

I'm just starting to understand how XNA wants the RasterizerState setup.

http://msdn.microsof...studio.40).aspx

My understanding is that you are supposed to define all the RasterizerStates that you intend to use as the game initializes and then just set the one you want when needed rather than trying to create a new RasterizerState every time it is needed. Apparently, defining a RasterizerState is a resource hog and so they one it all done once at startup.

I'm not even sure how the rasterization state is used with HLSL. I've never used it in HLSL, although it always exists. I would suspect there is a way to set it inside of HLSL, but I think it's normally set from XNA.

This post has been edited by BBeck: 28 July 2013 - 08:40 AM

Was This Post Helpful? 0
  • +
  • -

#7 BBeck  Icon User is online

  • Here to help.
  • member icon


Reputation: 560
  • View blog
  • Posts: 1,263
  • Joined: 24-April 12

Re: DirectX Errors

Posted 28 July 2013 - 08:42 AM

Incidentally, I have a DX11 book for you to read if you really want to understand what may be going on with this issue. But I warn you that its not light reading. It explains in hard-core C++ how DX manipulates the graphics card.

Before that though, I would recommend simply going back to a version of the code that actually did work and start over until you figure out what code you are adding that is causing it to go haywire.
Was This Post Helpful? 0
  • +
  • -

#8 rex64  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 168
  • Joined: 31-January 12

Re: DirectX Errors

Posted 29 July 2013 - 08:08 AM

Thanks, I think that gives me some ideas. Also, this happens when we double click the EXE from the debug folder. You may want to experiment with PIX and DebugView sometime.

DbgView.exe:
http://technet.micro...s/bb896647.aspx

And this is supposed to be great for DirectX and even normal program debugging:
http://tomtech999.wo...ix-for-windows/

We also use performance monitors to help streamline our code, but I would have to look that up (I assume you probably already know a good one).
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1