Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/doitsujin/dxvk.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Rebohle <philip.rebohle@tu-dortmund.de>2022-11-21 21:49:08 +0300
committerPhilip Rebohle <philip.rebohle@tu-dortmund.de>2022-11-21 21:49:24 +0300
commitabef13576c443afb571acbed699bc3eb4b1061fc (patch)
tree0e63b7e2fa69d890474d94f059fb2b4ab5dd7d06
parentc6611dffa7ba7aef5868b29bcac6ec1d79b7184b (diff)
[dxbc,d3d11] Don't access shex chunk if it is not definedshader-fix
-rw-r--r--src/d3d11/d3d11_shader.cpp17
-rw-r--r--src/dxbc/dxbc_module.h5
2 files changed, 15 insertions, 7 deletions
diff --git a/src/d3d11/d3d11_shader.cpp b/src/d3d11/d3d11_shader.cpp
index 3d6a0642..3753c075 100644
--- a/src/d3d11/d3d11_shader.cpp
+++ b/src/d3d11/d3d11_shader.cpp
@@ -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
diff --git a/src/dxbc/dxbc_module.h b/src/dxbc/dxbc_module.h
index d785d959..7609e232 100644
--- a/src/dxbc/dxbc_module.h
+++ b/src/dxbc/dxbc_module.h
@@ -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();
}