@@ -363,40 +363,35 @@ public static CompilationResult Compile(IntPtr textSource, int textSize, string
363363 if ( ! ( profile . ToUpperInvariant ( ) . StartsWith ( "FX_" ) || profile . ToUpperInvariant ( ) . StartsWith ( "LIB_" ) ) && string . IsNullOrWhiteSpace ( entryPoint ) )
364364 throw new ArgumentNullException ( "entryPoint" ) ;
365365
366- var resultCode = Result . Ok ;
367-
368366 Blob blobForCode = null ;
369367 Blob blobForErrors = null ;
370368
371- try
372- {
373- D3D . Compile2 (
374- ( IntPtr ) textSource ,
375- textSize ,
376- sourceFileName ,
377- PrepareMacros ( defines ) ,
378- IncludeShadow . ToIntPtr ( include ) ,
379- entryPoint ,
380- profile ,
381- shaderFlags ,
382- effectFlags ,
383- secondaryDataFlags ,
384- secondaryData != null ? secondaryData . DataPointer : IntPtr . Zero ,
385- secondaryData != null ? ( int ) secondaryData . Length : 0 ,
386- out blobForCode ,
387- out blobForErrors ) ;
388- }
389- catch ( SharpDXException ex )
369+ var resultCode = D3D . Compile2 (
370+ ( IntPtr ) textSource ,
371+ textSize ,
372+ sourceFileName ,
373+ PrepareMacros ( defines ) ,
374+ IncludeShadow . ToIntPtr ( include ) ,
375+ entryPoint ,
376+ profile ,
377+ shaderFlags ,
378+ effectFlags ,
379+ secondaryDataFlags ,
380+ secondaryData != null ? secondaryData . DataPointer : IntPtr . Zero ,
381+ secondaryData != null ? ( int ) secondaryData . Length : 0 ,
382+ out blobForCode ,
383+ out blobForErrors ) ;
384+
385+ if ( resultCode . Failure )
390386 {
391387 if ( blobForErrors != null )
392388 {
393- resultCode = ex . ResultCode ;
394389 if ( Configuration . ThrowOnShaderCompileError )
395- throw new CompilationException ( ex . ResultCode , Utilities . BlobToString ( blobForErrors ) ) ;
390+ throw new CompilationException ( resultCode , Utilities . BlobToString ( blobForErrors ) ) ;
396391 }
397392 else
398393 {
399- throw ;
394+ throw new SharpDXException ( resultCode ) ;
400395 }
401396 }
402397
@@ -475,7 +470,7 @@ public static CompilationResult CompileFromFile(string fileName,
475470 ShaderMacro [ ] defines = null ,
476471 Include include = null )
477472 {
478- return Compile ( NativeFile . ReadAllText ( fileName ) , entryPoint , profile , shaderFlags , effectFlags , defines , include ) ;
473+ return Compile ( NativeFile . ReadAllText ( fileName ) , entryPoint , profile , shaderFlags , effectFlags , defines , include , fileName ) ;
479474 }
480475
481476 // Win 8.1 SDK removed the corresponding functions from the WinRT platform
0 commit comments