diff --git a/src/HLSLCrossCompilerContext.cpp b/src/HLSLCrossCompilerContext.cpp index 73efca7..5ced2fd 100644 --- a/src/HLSLCrossCompilerContext.cpp +++ b/src/HLSLCrossCompilerContext.cpp @@ -72,12 +72,13 @@ void HLSLCrossCompilerContext::ClearDependencyData() case PIXEL_SHADER: { psDependencies->ClearCrossDependencyData(); + break; } case HULL_SHADER: { psDependencies->eTessPartitioning = TESSELLATOR_PARTITIONING_UNDEFINED; psDependencies->eTessOutPrim = TESSELLATOR_OUTPUT_UNDEFINED; - break; + break; } default: break; diff --git a/src/HLSLcc.cpp b/src/HLSLcc.cpp index 8b3bac1..2443a93 100644 --- a/src/HLSLcc.cpp +++ b/src/HLSLcc.cpp @@ -62,7 +62,16 @@ HLSLCC_API int HLSLCC_APIENTRY TranslateHLSLFromMem(const char* shader, sContext.psShader = psShader.get(); sContext.flags = flags; - sContext.psDependencies = dependencies; + + // If dependencies == NULL, we'll create a dummy object for it so that there's always something there. + std::auto_ptr depPtr(NULL); + if (dependencies == NULL) + { + depPtr.reset(new GLSLCrossDependencyData()); + sContext.psDependencies = depPtr.get(); + } + else + sContext.psDependencies = dependencies; for (i = 0; i < psShader->asPhases.size(); ++i) { diff --git a/src/reflect.cpp b/src/reflect.cpp index 58208b4..e77e16f 100644 --- a/src/reflect.cpp +++ b/src/reflect.cpp @@ -402,7 +402,7 @@ static void ReadResources(const uint32_t* pui32Tokens,//in psShaderInfo->psResourceBindings.clear(); psShaderInfo->psResourceBindings.resize(ui32NumResourceBindings); - psResBindings = &psShaderInfo->psResourceBindings[0]; + psResBindings = ui32NumResourceBindings == 0 ? NULL : &psShaderInfo->psResourceBindings[0]; for(i=0; i < ui32NumResourceBindings; ++i) { @@ -415,7 +415,7 @@ static void ReadResources(const uint32_t* pui32Tokens,//in psShaderInfo->psConstantBuffers.clear(); psShaderInfo->psConstantBuffers.resize(ui32NumConstantBuffers); - psConstantBuffers = &psShaderInfo->psConstantBuffers[0]; + psConstantBuffers = ui32NumConstantBuffers == 0 ? NULL : &psShaderInfo->psConstantBuffers[0]; for(i=0; i < ui32NumConstantBuffers; ++i) {