File tree 3 files changed +29
-15
lines changed
3 files changed +29
-15
lines changed Original file line number Diff line number Diff line change @@ -122,13 +122,17 @@ namespace Slang
122
122
{
123
123
switch (format)
124
124
{
125
- case ResultFormat::None:
126
125
default :
127
- break ;
128
-
126
+ case ResultFormat::None:
127
+ {
128
+ // If no blob is returned, it's an error
129
+ return SLANG_FAIL;
130
+ }
129
131
case ResultFormat::Text:
132
+ {
130
133
blob = StringUtil::createStringBlob (outputString);
131
134
break ;
135
+ }
132
136
case ResultFormat::Binary:
133
137
{
134
138
if (downstreamResult)
@@ -1968,7 +1972,11 @@ SlangResult dissassembleDXILUsingDXC(
1968
1972
case ResultFormat::Binary:
1969
1973
{
1970
1974
ComPtr<ISlangBlob> blob;
1971
- result.getBlob (blob);
1975
+ if (SLANG_FAILED (result.getBlob (blob)))
1976
+ {
1977
+ SLANG_UNEXPECTED (" No blob to emit" );
1978
+ return ;
1979
+ }
1972
1980
writeOutputFile (compileRequest,
1973
1981
outputPath,
1974
1982
blob->getBufferPointer (),
@@ -2020,6 +2028,7 @@ SlangResult dissassembleDXILUsingDXC(
2020
2028
ComPtr<ISlangBlob> blob;
2021
2029
if (SLANG_FAILED (result.getBlob (blob)))
2022
2030
{
2031
+ SLANG_UNEXPECTED (" No blob to emit" );
2023
2032
return ;
2024
2033
}
2025
2034
Original file line number Diff line number Diff line change @@ -2598,7 +2598,12 @@ void CPPSourceEmitter::emitModuleImpl(IRModule* module)
2598
2598
targetProgram->getOrCreateEntryPointResult (index , &sink);
2599
2599
2600
2600
Slang::ComPtr<ISlangBlob> blob;
2601
- result.getBlob (blob);
2601
+ if (SLANG_FAILED (result.getBlob (blob)))
2602
+ {
2603
+ SLANG_UNEXPECTED (" No blob to emit" );
2604
+ return ;
2605
+ }
2606
+
2602
2607
auto ptr = (const unsigned char *)blob->getBufferPointer ();
2603
2608
2604
2609
m_writer->emit (" size_t __" );
Original file line number Diff line number Diff line change @@ -3390,6 +3390,13 @@ SLANG_API void const* spGetEntryPointCode(
3390
3390
size_t * outSize)
3391
3391
{
3392
3392
using namespace Slang ;
3393
+
3394
+ // Zero the size initially, in case need to return nullptr for error.
3395
+ if (outSize)
3396
+ {
3397
+ *outSize = 0 ;
3398
+ }
3399
+
3393
3400
auto req = Slang::asInternal (request);
3394
3401
auto linkage = req->getLinkage ();
3395
3402
auto program = req->getSpecializedGlobalAndEntryPointsComponentType ();
@@ -3411,22 +3418,15 @@ SLANG_API void const* spGetEntryPointCode(
3411
3418
return nullptr ;
3412
3419
CompileResult& result = targetProgram->getExistingEntryPointResult (entryPointIndex);
3413
3420
3414
- void const * data = nullptr ;
3415
- size_t size = 0 ;
3416
-
3417
3421
ComPtr<ISlangBlob> blob;
3418
- if (SLANG_SUCCEEDED (result.getBlob (blob)))
3419
- {
3420
- data = blob->getBufferPointer ();
3421
- size = blob->getBufferSize ();
3422
- }
3422
+ SLANG_RETURN_NULL_ON_FAIL (result.getBlob (blob));
3423
3423
3424
3424
if (outSize)
3425
3425
{
3426
- *outSize = size ;
3426
+ *outSize = blob-> getBufferSize () ;
3427
3427
}
3428
3428
3429
- return data ;
3429
+ return ( void *)blob-> getBufferPointer () ;
3430
3430
}
3431
3431
3432
3432
static SlangResult _getEntryPointResult (
You can’t perform that action at this time.
0 commit comments