Jump to content
  • Advertisement
Sign in to follow this  

Strange Effect problem

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

Hello! I've got another problem: The Effect-File, made by my Shader-Editor, can get compiled without any problems. I do it with D3D10PreprocessShader(), which precompiles the Shader and puts the data into a Blob-Interface. This Blob is saved to a Package file, but this has nothing to do with the problem. Right after precompiling, I want to create the Effect via D3DX10CreateEffectFromMemory(). DirectX10 returns S_OK here, but then, those strange things appear: I have only 1 technique in that shader, but some other are using 2. So I allways try to get both:

As they both were NULL before that, they both got now the memory-address! And thats not all: I want to create the Input layout after this, but when I try to get the pass (Only 1 in the shader), DX10 doesn't find it, I think, because all members of the PassDesc structure are the same as before the call. And so, the CreateInputLayout() call fails. Here is the sourcecode of all that:
SaveScintillaToFile("TempShader.fx",ShaderEditor.Scintillahw);  //Save the Editor-Contents to a textfile
			TheScene.PckHandler->FindPackageByName(LPS ShaderEditor.FilePackage,&Pck); //Find the right Package
				WCHAR Source[MAX_PATH];

				wcscpy(LPS Source,LPS ShaderEditor.LoadedFile);
				wcscat(LPS Source,L".Source"); //Apply .Source, for the Package-version of the shader


				ID3D10Blob* ShaderBlob;
				ID3D10Blob*	Blob_Errors;
				//First try to precompile, I don't think, that this was the right function
				//D3DX10CompileFromFile(L"TempShader.fx", NULL, NULL,NULL, "fx_4_0", D3D10_SHADER_ENABLE_STRICTNESS, NULL, NULL, &ShaderBlob,&Blob_Errors,NULL);
				byte* Data;
				UINT Size;

				//Get the Data of the TempShader.fx file (from disk)

				WShaderInclude Inc; //Include Interface
				D3D10PreprocessShader((LPCSTR)Data,Size,NULL,NULL,&Inc,&ShaderBlob,&Blob_Errors); //Precompile it!

				delete[] Data;
				char* Errors;
				if(Blob_Errors) //I get no error messages...
					Errors=(char *)Blob_Errors->GetBufferPointer();

					CHAR Msg[1024];

					strcpy((char *)&Msg,Errors);

					MessageBoxA(NULL,(char *)&Msg,"There are errors in that file!",MB_OK | MB_ICONERROR);

					InfoBox(L"Compilation succeeded!"); //... so the compilation succeeds
					Pck->AppendMemory(LPS ShaderEditor.LoadedFile,ShaderBlob->GetBufferPointer(),ShaderBlob->GetBufferSize()); //Append the precompiled shader to the package

					Pck->AppendFile(L"TempShader.fx",LPS Source); //Append the sourcecode for later editing

					TreeInfo* TI;
					Browser.GetTreeInfoByTreeItem(ShaderEditor.TreeItem,&TI); //Get the TargetShader

					WShader* Shd=(WShader *)TI->Target;
					Shd->CreateShaderFromFile(NULL,NULL,NULL,ShaderBlob->GetBufferPointer(),ShaderBlob->GetBufferSize(),true); //Compile it


The Create-Effect function:
HRESULT WShader::CreateShaderFromFile(LPWSTR Path,LPWSTR Package,LPWSTR File,LPVOID Memory,long MemSize,bool bIKnowWhatIAmDoingWhenIPassNoPackageInformation,bool bPooled)

	WCHAR Dir[256];

			WarnBox(L"Warning! [w]tech is about to load a Shader from a file! This is NOT recommend!");
				ErrorBox(L"Error! You passed a path without any characters to CreateShaderFromFile()!");
				return E_FAIL;
				ErrorBox(L"Error! You passed a Package-Name without any characters to CreateShaderFromFile()!");
				return E_FAIL;

				ErrorBox(L"Error! You passed a File-Name in a package without any characters to CreateShaderFromFile()!");
				return E_FAIL;
		CheckNULL(Package)wcscpy(LPS ShaderFileInfo.Package,Package); //Save, where we found the Shader
		CheckNULL(File)wcscpy(LPS ShaderFileInfo.File,File);
		CheckNULL(Path)wcscpy(LPS ImportPath,Path);
	GetCurrentDirectory(256,LPS Dir); //Debuging

	Cleanup(); //if we already have some data
	ID3D10EffectPool* Pool=NULL;

	if(SharedParams && bPooled==true)
		Pool=(ID3D10EffectPool*)(*SharedParams->EffectPool); //Use a pool, if we want to

		wcscpy(LPS ImportPackage,Path); //Create one from a file, THATS NOT GOOD!
		V_RETURN(D3DX10CreateEffectFromFile( Path, NULL, NULL, "fx_4_0", dwShaderFlags, 0, DXUTGetD3D10Device(), Pool,
                                              NULL, &MyShader, NULL, NULL ) );
		if(bPooled) //Pooled or not?
			WShaderInclude Inc;

			//void* ShaderData;
			//UINT DataSize;
			//Inc.Open(D3D10_INCLUDE_LOCAL,"wTechBaseShader.fx",Memory,(LPCVOID *)&ShaderData,&DataSize);
			V_RETURN(D3DX10CreateEffectFromMemory(Memory,MemSize,"None",0,&Inc, "fx_4_0", dwShaderFlags, 0, DXUTGetD3D10Device(), Pool,
												  NULL, &MyShader, NULL, NULL ) );

		{//Not pooled
			V_RETURN(D3DX10CreateEffectFromMemory(Memory,MemSize,"None",0,0, "fx_4_0", dwShaderFlags, 0, DXUTGetD3D10Device(), Pool,
												  NULL, &MyShader, NULL, NULL ) ); //Succeeds!
	NormalRenderTechnique=MyShader->GetTechniqueByName("RenderTechnique"); //Get the techniques <--- seems to fail


	UINT numElements = sizeof( BasicVertexLayout ) / sizeof( BasicVertexLayout[0] );

    // Create the input layout
    D3D10_PASS_DESC PassDesc;
    RenderTechnique->GetPassByIndex( 0 )->GetDesc( &PassDesc ); //<--- Seems to fail!
    V_RETURN( DXUTGetD3D10Device()->CreateInputLayout( BasicVertexLayout, numElements, PassDesc.pIAInputSignature,
                                             PassDesc.IAInputSignatureSize, &VertexLayout ) ); //Create the layout


Any suggestions?

Share this post

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!