Skip to content
This repository was archived by the owner on Mar 30, 2019. It is now read-only.

Commit 9e44e83

Browse files
committed
Fix error handling in ShaderBytecode.Compile.
1 parent a95eab8 commit 9e44e83

1 file changed

Lines changed: 19 additions & 24 deletions

File tree

Source/SharpDX.D3DCompiler/ShaderBytecode.cs

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)