Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualMichael Tanczos

Posted 28 December 2012 - 12:30 AM

ok so im not sure i have really narrowed it down to this point as the try catch block does not catch the exception, but when i do not allow the texture to be written to, then it stops crashing. the map function is as follows,


try

{

// if everything is in order then send data to graphics memory.

if (pTexture != null)

{

DataBox mappedTex = null;

//assign and lock the resource

mappedTex = g_pd3dDevice.ImmediateContext.MapSubresource(pTexture, 0, pTexture.Description.Height * pTexture.Description.Width*4, D3D11.MapMode.WriteDiscard, D3D11.MapFlags.None);

// if unable to hold texture

if (!mappedTex.Data.CanWrite)

{ throw new InvalidOperationException("Cannot Write to the Texture"); }

// write new data to the texture

mappedTex.Data.WriteRange<byte>(NewData);

// unlock the resource

g_pd3dDevice.ImmediateContext.UnmapSubresource(pTexture, 0);

}

}

catch (Exception P)

{

MessageBox.Show("texheight = " + pTexture.Description.Height + " \n" + "texwidth = " + pTexture.Description.Width + "\n" + "data size = " + NewData.Length);

throw;

}




could this be some kind of threading issue with the ImmediateContext ? there was some issue with having to move from a datarectangle to a databox as well.


#1ucfchuck

Posted 13 December 2012 - 03:53 PM

ok so im not sure i have really narrowed it down to this point as the try catch block does not catch the exception, but when i do not allow the texture to be written to, then it stops crashing. the map function is as follows,
[source lang="csharp"] try { // if everything is in order then send data to graphics memory. if (pTexture != null) { DataBox mappedTex = null; //assign and lock the resource mappedTex = g_pd3dDevice.ImmediateContext.MapSubresource(pTexture, 0, pTexture.Description.Height * pTexture.Description.Width*4, D3D11.MapMode.WriteDiscard, D3D11.MapFlags.None); // if unable to hold texture if (!mappedTex.Data.CanWrite) { throw new InvalidOperationException("Cannot Write to the Texture"); } // write new data to the texture mappedTex.Data.WriteRange<byte>(NewData); // unlock the resource g_pd3dDevice.ImmediateContext.UnmapSubresource(pTexture, 0); } } catch (Exception P) { MessageBox.Show("texheight = " + pTexture.Description.Height + " \n" + "texwidth = " + pTexture.Description.Width + "\n" + "data size = " + NewData.Length); throw; }[/source]


could this be some kind of threading issue with the ImmediateContext ? there was some issue with having to move from a datarectangle to a databox as well.

PARTNERS