1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-13 19:29:14 +01:00

[dxbc,d3d11] Don't access shex chunk if it is not defined

This commit is contained in:
Philip Rebohle 2022-11-21 19:49:08 +01:00
parent d01c9cb6d4
commit 4f90d7bf5f
2 changed files with 15 additions and 7 deletions

View File

@ -20,8 +20,6 @@ namespace dxvk {
reinterpret_cast<const char*>(pShaderBytecode),
BytecodeLength);
DxbcModule module(reader);
// If requested by the user, dump both the raw DXBC
// shader and the compiled SPIR-V module to a file.
const std::string& dumpPath = pDevice->GetOptions()->shaderDumpPath;
@ -30,14 +28,21 @@ namespace dxvk {
reader.store(std::ofstream(str::topath(str::format(dumpPath, "/", name, ".dxbc").c_str()).c_str(),
std::ios_base::binary | std::ios_base::trunc));
}
// Error out if the shader is invalid
DxbcModule module(reader);
auto programInfo = module.programInfo();
if (!programInfo)
throw DxvkError("Invalid shader binary.");
// Decide whether we need to create a pass-through
// geometry shader for vertex shader stream output
bool passthroughShader = pDxbcModuleInfo->xfb != nullptr
&& (module.programInfo().type() == DxbcProgramType::VertexShader
|| module.programInfo().type() == DxbcProgramType::DomainShader);
&& (programInfo->type() == DxbcProgramType::VertexShader
|| programInfo->type() == DxbcProgramType::DomainShader);
if (module.programInfo().shaderStage() != pShaderKey->type() && !passthroughShader)
if (programInfo->shaderStage() != pShaderKey->type() && !passthroughShader)
throw DxvkError("Mismatching shader type.");
m_shader = passthroughShader

View File

@ -35,7 +35,10 @@ namespace dxvk {
* \brief Shader type
* \returns Shader type
*/
DxbcProgramInfo programInfo() const {
std::optional<DxbcProgramInfo> programInfo() const {
if (m_shexChunk == nullptr)
return std::nullopt;
return m_shexChunk->programInfo();
}