Sign in to follow this  
jdub

Program fails with access violation while trying to compile shader

Recommended Posts

This is really tripping me up as I can't seem to figure out what could be wrong with this piece of code:

ID3DBlob *vShaderCode = NULL;
ID3DBlob *pShaderCode = NULL;
ID3DBlob *errorCode = NULL;

		if(FAILED(D3DCompileFromFile(GetFilePath(L"nbody_simulation\\VSPointSprite.hlsl").data(), NULL, NULL, NULL, "vs_5_0", flags1, 0, &vShaderCode, &errorCode)))
		{
			SafeRelease<ID3DBlob>(&vShaderCode);	
			if(errorCode)
			{
				OutputDebugStringA((LPCSTR)errorCode->GetBufferPointer());
				SafeRelease<ID3DBlob>(&errorCode);
			}

			return false;
		}


...
... Implementation of GetFilePath() in separate header file

const std::wstring appPath = L"C:\\Users\\Jared\\Documents\\Visual Studio 2012\\Projects\\nbody_simulation\\";

inline std::wstring GetFilePath(const std::wstring &fileName)
{
	std::wstring tmp = std::wstring(appPath.data());
	return tmp.append(fileName.data());
}
 

I get the following error on the line where I call D3DCompileFromFile():  Unhandled exception at 0x54469A72 (D3Dcompiler_46.dll) in nbody_simulation.exe: 0xC0000005: Access violation writing location 0x00000018.

 

Any ideas?

Edited by jdub

Share this post


Link to post
Share on other sites

Have you tried the code to compile a known good shader?  Do you suspect that your usage of the function is incorrect, or that one of your arguments isn't initialized, or possibly that your GetFilePath method isn't returning what it should be?

Share this post


Link to post
Share on other sites

you are calling D3DCompileFromFile with wrong args (please check the retrurn value, must be something like E_INVALIDARG).

 

http://msdn.microsoft.com/en-us/library/windows/desktop/hh446872(v=vs.85).aspx you must specify the entry point of the shader.

Edited by imoogiBG

Share this post


Link to post
Share on other sites

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