• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By isu diss
      How do I fill the gap between sky and terrain? Scaling the terrain or procedural terrain rendering?

    • By Jiraya
      For a 2D game, does using a float2 for position increases performance in any way?
      I know that in the end the vertex shader will have to return a float4 anyway, but does using a float2 decreases the amount of data that will have to be sent from the CPU to the GPU?
       
    • By ucfchuck
      I am feeding in 16 bit unsigned integer data to process in a compute shader and i need to get a standard deviation.
      So I read in a series of samples and push them into float arrays
      float vals1[9], vals2[9], vals3[9], vals4[9]; int x = 0,y=0; for ( x = 0; x < 3; x++) { for (y = 0; y < 3; y++) { vals1[3 * x + y] = (float) (asuint(Input1[threadID.xy + int2(x - 1, y - 1)].x)); vals2[3 * x + y] = (float) (asuint(Input2[threadID.xy + int2(x - 1, y - 1)].x)); vals3[3 * x + y] = (float) (asuint(Input3[threadID.xy + int2(x - 1, y - 1)].x)); vals4[3 * x + y] = (float) (asuint(Input4[threadID.xy + int2(x - 1, y - 1)].x)); } } I can send these values out directly and the data is as expected

                             
      Output1[threadID.xy] = (uint) (vals1[4] ); Output2[threadID.xy] = (uint) (vals2[4] ); Output3[threadID.xy] = (uint) (vals3[4] ); Output4[threadID.xy] = (uint) (vals4[4] ); however if i do anything to that data it is destroyed.
      If i add a
      vals1[4] = vals1[4]/2; 
      or a
      vals1[4] = vals[1]-vals[4];
      the data is gone and everything comes back 0.
       
       
      How does one go about converting a uint to a float and performing operations on it and then converting back to a rounded uint?
    • By fs1
      I have been trying to see how the ID3DInclude, and how its methods Open and Close work.
      I would like to add a custom path for the D3DCompile function to search for some of my includes.
      I have not found any working example. Could someone point me on how to implement these functions? I would like D3DCompile to look at a custom C:\Folder path for some of the include files.
      Thanks
    • By stale
      I'm continuing to learn more about terrain rendering, and so far I've managed to load in a heightmap and render it as a tessellated wireframe (following Frank Luna's DX11 book). However, I'm getting some really weird behavior where a large section of the wireframe is being rendered with a yellow color, even though my pixel shader is hard coded to output white. 

      The parts of the mesh that are discolored changes as well, as pictured below (mesh is being clipped by far plane).

      Here is my pixel shader. As mentioned, I simply hard code it to output white:
      float PS(DOUT pin) : SV_Target { return float4(1.0f, 1.0f, 1.0f, 1.0f); } I'm completely lost on what could be causing this, so any help in the right direction would be greatly appreciated. If I can help by providing more information please let me know.
  • Advertisement
  • Advertisement
Sign in to follow this  

DX11 Unhandle Exception During Release/Shutdown of a texture

This topic is 1893 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

Currently Writing a new system, and I've put a small box with a texture on it, with DirectX11 (which was previously working before I started adding more unrelated code).

 

Now for some unknown reason, I've receiving this unhandled exception:

 

http://img15.imageshack.us/img15/5666/textureunload.png

 

Continuing will loop the same problem. I'm probably missing something really stupid, but I'd really like some insight to why this is happening.. Thanks!

 

 

Texture.cpp

#include "Texture.h"

/* Constructor & Deconstructor */
Texture::Texture()
{
	m_texture = 0;
}
Texture::~Texture(){}

/* Initialize */
bool Texture::Init(ID3D11Device* device, CHAR* filename)
{
	HRESULT r;

	//Load texture
	r = D3DX11CreateShaderResourceViewFromFile(device, filename, NULL, NULL, &m_texture, NULL);
	if(FAILED(r))
	{return false;}

	return true;
}

/* Return objects we are using to higher level */
ID3D11ShaderResourceView* Texture::GetTexture()
{return m_texture;}

/* Shutdown/Release Objects we have used */
void Texture::Shutdown()
{
	if(m_texture)
	{
		m_texture->Release();
		m_texture = 0;
	}
	return;
}
Edited by Xuchilbara

Share this post


Link to post
Share on other sites
Advertisement

Your "this" pointer is bogus inside of Model::ReleaseTexture. 0xcdcdcdcdcd is the default fill pattern for memory allocated from the heap, so this means that you allocated something with a Model* pointer that was never initialized to anything. Then you tried to call ReleaseTexture on that initialized pointer, and your program crashed when it tried to follow access memory using that invalid pointer (in your case it tried to access m_texture member of Model which is located at an offset of 16 bytes from the start of your Model class, which is why it's complaining about accessing memory at an address off 0xcdcdcddd).

Share this post


Link to post
Share on other sites

Im not quite sure I follow, I have allocated m_modeltype to ModelType

 

		struct ModelType
		{
			float x, y, z;
			float tu, tv;
			float nx, ny, nz;
		};



ModelType* m_modeltype;

 

And then initialized in the LoadModel() function

 

//Create the model using the vertex count that was read in
	m_modeltype = new ModelType[m_vertexCount];
	if(!m_modeltype)
	{return false;}

Share this post


Link to post
Share on other sites

Does your texture work at runtime after you made your changes?

 

Also, I don't think I'm seeing enough code to accurately pinpoint what's going on.  Can you show us what you changed?

 

Shogun

Edited by blueshogun96

Share this post


Link to post
Share on other sites
In your screenshot, the error is occuring in the Model class, not your ModelType struct.
It looks like you're calling Model::ReleaseTexture on an object that hasn't been created, or on an object that has been deleted.
e.g.
Model* model;
model->ReleaseTexture();//crash
//or
Model* model = new Model();
delete model;
model->ReleaseTexture();//crash
Edited by Hodgman

Share this post


Link to post
Share on other sites

When the unhandled exception occurs, break into the debugger. Go to the call stack window, you'll be in Model::ReleaseTexture. Go down in the stack to the previous function that called ReleaseTexture. In this function it will be calling ReleaseTexture on a Model* pointer. This pointer variable is bogus, it was never initialized to any value.

Share this post


Link to post
Share on other sites

Here is the shutdown function of my model.cpp 

void Model::Shutdown()
{
	//Release the model texture
	ReleaseTexture();

	//Release the vertex and index buffers
	ShutdownBuffers();

	//Release the model
	ReleaseModel();

	return;
}

 

It seems that every single of these functions return a problem when it accesses them, starting with ReleaseTexture() as its at the top. Although after doing some debugging it turns out it's going straight for the Shutdown() method and not the Init() Method during compile, in fact it completely ignores the initialization in the top end class.

 

Application.cpp

	/* CUBE */
	m_Cube = new Model;
	if(!m_Cube)
	{return false;}

	r = m_Cube->Init(m_D3D->GetDevice(), "Shapes/Cube.txt", "Textures/blocktexture.jpg");
	if(!r)
	{
		MessageBox(hwnd, "Cube Failed to load!", "Error!", MB_OK);
		return false;
	}

 

Why is it skipping directly to the Shutdown() function in my Application class first?

 

void Application::Shutdown()
{
	if(m_Cube)
	{
		m_Cube->Shutdown();
		delete m_Cube;
		m_Cube = 0;
	}

...
}
Edited by Xuchilbara

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement