[dxvk] Improve debuggability of shader compiler issues

When using DXVK_LOG_LEVEL=debug, the graphics pipeline manager now
prints the names of the shaders used by the pipeline. This shall
help debug driver crashes in vkCreate*Pipelines.
This commit is contained in:
Philip Rebohle 2018-02-07 16:44:30 +01:00
parent 0f13914ff0
commit ad6c45d6b1
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
6 changed files with 53 additions and 5 deletions

View File

@ -37,7 +37,8 @@ namespace dxvk {
}
m_shader = module.compile(*pDxbcOptions);
m_shader->setDebugName(m_name);
if (dumpPath.size() != 0) {
m_shader->dump(std::ofstream(str::format(dumpPath, "/", m_name, ".spv"),
std::ios_base::binary | std::ios_base::trunc));

View File

@ -94,6 +94,9 @@ namespace dxvk {
VkPipeline DxvkGraphicsPipeline::compilePipeline(
const DxvkGraphicsPipelineStateInfo& state,
VkPipeline baseHandle) const {
if (Logger::logLevel() <= LogLevel::Debug)
this->logPipelineState(state);
std::array<VkDynamicState, 4> dynamicStates = {
VK_DYNAMIC_STATE_VIEWPORT,
VK_DYNAMIC_STATE_SCISSOR,
@ -304,4 +307,18 @@ namespace dxvk {
return VK_RASTERIZATION_ORDER_STRICT_AMD;
}
void DxvkGraphicsPipeline::logPipelineState(
const DxvkGraphicsPipelineStateInfo& state) const {
Logger::debug("Compiling graphics pipeline...");
if (m_vs != nullptr) Logger::debug(str::format(" vs : ", m_vs ->debugName()));
if (m_tcs != nullptr) Logger::debug(str::format(" tcs : ", m_tcs->debugName()));
if (m_tes != nullptr) Logger::debug(str::format(" tes : ", m_tes->debugName()));
if (m_gs != nullptr) Logger::debug(str::format(" gs : ", m_gs ->debugName()));
if (m_fs != nullptr) Logger::debug(str::format(" fs : ", m_fs ->debugName()));
// TODO log more pipeline state
}
}

View File

@ -162,6 +162,9 @@ namespace dxvk {
VkRasterizationOrderAMD pickRasterizationOrder(
const DxvkGraphicsPipelineStateInfo& state) const;
void logPipelineState(
const DxvkGraphicsPipelineStateInfo& state) const;
};
}

View File

@ -5,8 +5,9 @@ namespace dxvk {
DxvkShaderModule::DxvkShaderModule(
const Rc<vk::DeviceFn>& vkd,
VkShaderStageFlagBits stage,
const SpirvCodeBuffer& code)
: m_vkd(vkd), m_stage(stage) {
const SpirvCodeBuffer& code,
const std::string& name)
: m_vkd(vkd), m_stage(stage), m_debugName(name) {
VkShaderModuleCreateInfo info;
info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
info.pNext = nullptr;
@ -81,7 +82,7 @@ namespace dxvk {
}
}
return new DxvkShaderModule(vkd, m_stage, spirvCode);
return new DxvkShaderModule(vkd, m_stage, spirvCode, m_debugName);
}

View File

@ -37,7 +37,8 @@ namespace dxvk {
DxvkShaderModule(
const Rc<vk::DeviceFn>& vkd,
VkShaderStageFlagBits stage,
const SpirvCodeBuffer& code);
const SpirvCodeBuffer& code,
const std::string& name);
~DxvkShaderModule();
@ -58,11 +59,20 @@ namespace dxvk {
VkPipelineShaderStageCreateInfo stageInfo(
const VkSpecializationInfo* specInfo) const;
/**
* \brief The shader's debug name
* \returns Debug name
*/
const std::string& debugName() const {
return m_debugName;
}
private:
Rc<vk::DeviceFn> m_vkd;
VkShaderStageFlagBits m_stage;
VkShaderModule m_module;
std::string m_debugName;
};
@ -137,6 +147,17 @@ namespace dxvk {
*/
void read(std::istream&& inputStream);
/**
* \brief Sets the shader's debug name
*
* Debug names may be used by the backend in
* order to help debug shader compiler issues.
* \param [in] name The shader's name
*/
void setDebugName(const std::string& name) {
m_debugName = name;
}
private:
VkShaderStageFlagBits m_stage;
@ -144,6 +165,7 @@ namespace dxvk {
std::vector<DxvkResourceSlot> m_slots;
DxvkInterfaceSlots m_interface;
std::string m_debugName;
};

View File

@ -35,6 +35,10 @@ namespace dxvk {
static void warn (const std::string& message);
static void err (const std::string& message);
static LogLevel logLevel() {
return s_instance.m_minLevel;
}
private:
static Logger s_instance;