diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-07-13 08:36:47 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-07-13 08:36:47 -0700 |
| commit | 72a3e97fe6bfdffee253ad008cab7cdd3b9e796f (patch) | |
| tree | 87632574baf942509e1ebfcf45cb5dbfc6668112 /source | |
| parent | f48035ff26381d8bc22a7e484eda53fc087ae7b7 (diff) | |
Allow `spGetEntryPointCode` to return text results too
Fixes #77
- The `spGetEntryPointSource` function is now no longer needed, but I'm not going to "deprecate" it just yet
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 0561f30a9..bfc499c1b 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -880,8 +880,29 @@ SLANG_API void const* spGetEntryPointCode( { auto req = REQ(request); Slang::CompileResult& result = req->entryPoints[entryPointIndex]->result; - if(outSize) *outSize = result.outputBinary.Count(); - return result.outputBinary.Buffer(); + + void const* data = nullptr; + size_t size = 0; + + switch (result.format) + { + case Slang::ResultFormat::None: + default: + break; + + case Slang::ResultFormat::Binary: + data = result.outputBinary.Buffer(); + size = result.outputBinary.Count(); + break; + + case Slang::ResultFormat::Text: + data = result.outputString.Buffer(); + size = result.outputString.Length(); + break; + } + + if(outSize) *outSize = size; + return data; } // Reflection API |
