XNA Creators Club Online
Page 1 of 1 (7 items)
Sort Posts: Previous Next

From XNA 1.0 to 2.0

Last post 07-20-2008 9:25 AM by Harald Maassen. 6 replies.
  • 07-19-2008 11:30 PM

    From XNA 1.0 to 2.0

    I took a year off from XNA to work on other stuff. I recently found some time to open up some of my projects. The project I am working on was started in XNA 1.0. I have followed all the guidelines for moving it up to 2.0. I am still getting an exception. I cannot understand why. This is the exception I am getting

    System.InvalidOperationException was unhandled
      Message="The operation was aborted. You may not modify a resource that has been set on a device, or after it has been used within a tiling bracket."
     

    It happens at an IndexBuffer.setdata call. The documentation briefly mentions this, but I am not clear on why this exception gets thrown in 2.0 but not 1.0.  Can any one help me with this? Thanks!

  • 07-20-2008 7:16 AM In reply to

    Re: From XNA 1.0 to 2.0

    Here is the quote from the XNA documentation under IndexBuffer.SetData<>.

    Remarks

    An InvalidOperationException is thrown if an attempt is made to modify (for example, calls to the GetData or SetData methods) a resource that is currently set on a graphics device.
     
    Can anyone explain what a resource being "set" on a graphics device means. Does this mean I am trying to setdata on abuffer that is still in use by the GPU?
  • 07-20-2008 7:35 AM In reply to

    Re: From XNA 1.0 to 2.0


    MarkF:
    Can anyone explain what a resource being "set" on a graphics device means.

    For an index Buffer, it means that  GraphicsDevice.Indices has the value of that index buffer

    For vertex Buffers, it means GraphicsDevice.Vertices[.SetSource() was recently used with that vertex buffer as a parameter, maybe for drawing something. Even though it may not be used at this moment, it is still prepared on the device for usage, so you cannot modify it.

  • 07-20-2008 7:59 AM In reply to

    Re: From XNA 1.0 to 2.0

    Thanks for the reply. How do I know when it's safe to modify a resource?
  • 07-20-2008 8:08 AM In reply to

    Re: From XNA 1.0 to 2.0

    You don't have to wait, or check anything.

    Just make sure the buffers are no longer set on the device:

     GraphicsDevice.Indices = null;

    GraphicsDevice.Vertices[0].SetSource(null, 0, 0);

     

     


  • 07-20-2008 8:28 AM In reply to

    Re: From XNA 1.0 to 2.0

    sweet and simple! Thanks! I wonder why I never ran into this problem in XNA 1.0. Same code same machine.
  • 07-20-2008 9:25 AM In reply to

    Re: From XNA 1.0 to 2.0

    I think this would actually cause bugs in 1.0, which is why 2.0 added the exception.
Page 1 of 1 (7 items) Previous Next
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG