mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-02 22:29:16 +01:00
[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:
parent
0f13914ff0
commit
ad6c45d6b1
@ -37,7 +37,8 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_shader = module.compile(*pDxbcOptions);
|
m_shader = module.compile(*pDxbcOptions);
|
||||||
|
m_shader->setDebugName(m_name);
|
||||||
|
|
||||||
if (dumpPath.size() != 0) {
|
if (dumpPath.size() != 0) {
|
||||||
m_shader->dump(std::ofstream(str::format(dumpPath, "/", m_name, ".spv"),
|
m_shader->dump(std::ofstream(str::format(dumpPath, "/", m_name, ".spv"),
|
||||||
std::ios_base::binary | std::ios_base::trunc));
|
std::ios_base::binary | std::ios_base::trunc));
|
||||||
|
@ -94,6 +94,9 @@ namespace dxvk {
|
|||||||
VkPipeline DxvkGraphicsPipeline::compilePipeline(
|
VkPipeline DxvkGraphicsPipeline::compilePipeline(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state,
|
||||||
VkPipeline baseHandle) const {
|
VkPipeline baseHandle) const {
|
||||||
|
if (Logger::logLevel() <= LogLevel::Debug)
|
||||||
|
this->logPipelineState(state);
|
||||||
|
|
||||||
std::array<VkDynamicState, 4> dynamicStates = {
|
std::array<VkDynamicState, 4> dynamicStates = {
|
||||||
VK_DYNAMIC_STATE_VIEWPORT,
|
VK_DYNAMIC_STATE_VIEWPORT,
|
||||||
VK_DYNAMIC_STATE_SCISSOR,
|
VK_DYNAMIC_STATE_SCISSOR,
|
||||||
@ -304,4 +307,18 @@ namespace dxvk {
|
|||||||
return VK_RASTERIZATION_ORDER_STRICT_AMD;
|
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
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -162,6 +162,9 @@ namespace dxvk {
|
|||||||
VkRasterizationOrderAMD pickRasterizationOrder(
|
VkRasterizationOrderAMD pickRasterizationOrder(
|
||||||
const DxvkGraphicsPipelineStateInfo& state) const;
|
const DxvkGraphicsPipelineStateInfo& state) const;
|
||||||
|
|
||||||
|
void logPipelineState(
|
||||||
|
const DxvkGraphicsPipelineStateInfo& state) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
@ -5,8 +5,9 @@ namespace dxvk {
|
|||||||
DxvkShaderModule::DxvkShaderModule(
|
DxvkShaderModule::DxvkShaderModule(
|
||||||
const Rc<vk::DeviceFn>& vkd,
|
const Rc<vk::DeviceFn>& vkd,
|
||||||
VkShaderStageFlagBits stage,
|
VkShaderStageFlagBits stage,
|
||||||
const SpirvCodeBuffer& code)
|
const SpirvCodeBuffer& code,
|
||||||
: m_vkd(vkd), m_stage(stage) {
|
const std::string& name)
|
||||||
|
: m_vkd(vkd), m_stage(stage), m_debugName(name) {
|
||||||
VkShaderModuleCreateInfo info;
|
VkShaderModuleCreateInfo info;
|
||||||
info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
||||||
info.pNext = nullptr;
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,7 +37,8 @@ namespace dxvk {
|
|||||||
DxvkShaderModule(
|
DxvkShaderModule(
|
||||||
const Rc<vk::DeviceFn>& vkd,
|
const Rc<vk::DeviceFn>& vkd,
|
||||||
VkShaderStageFlagBits stage,
|
VkShaderStageFlagBits stage,
|
||||||
const SpirvCodeBuffer& code);
|
const SpirvCodeBuffer& code,
|
||||||
|
const std::string& name);
|
||||||
|
|
||||||
~DxvkShaderModule();
|
~DxvkShaderModule();
|
||||||
|
|
||||||
@ -58,11 +59,20 @@ namespace dxvk {
|
|||||||
VkPipelineShaderStageCreateInfo stageInfo(
|
VkPipelineShaderStageCreateInfo stageInfo(
|
||||||
const VkSpecializationInfo* specInfo) const;
|
const VkSpecializationInfo* specInfo) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief The shader's debug name
|
||||||
|
* \returns Debug name
|
||||||
|
*/
|
||||||
|
const std::string& debugName() const {
|
||||||
|
return m_debugName;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Rc<vk::DeviceFn> m_vkd;
|
Rc<vk::DeviceFn> m_vkd;
|
||||||
VkShaderStageFlagBits m_stage;
|
VkShaderStageFlagBits m_stage;
|
||||||
VkShaderModule m_module;
|
VkShaderModule m_module;
|
||||||
|
std::string m_debugName;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -137,6 +147,17 @@ namespace dxvk {
|
|||||||
*/
|
*/
|
||||||
void read(std::istream&& inputStream);
|
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:
|
private:
|
||||||
|
|
||||||
VkShaderStageFlagBits m_stage;
|
VkShaderStageFlagBits m_stage;
|
||||||
@ -144,6 +165,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
std::vector<DxvkResourceSlot> m_slots;
|
std::vector<DxvkResourceSlot> m_slots;
|
||||||
DxvkInterfaceSlots m_interface;
|
DxvkInterfaceSlots m_interface;
|
||||||
|
std::string m_debugName;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,6 +35,10 @@ namespace dxvk {
|
|||||||
static void warn (const std::string& message);
|
static void warn (const std::string& message);
|
||||||
static void err (const std::string& message);
|
static void err (const std::string& message);
|
||||||
|
|
||||||
|
static LogLevel logLevel() {
|
||||||
|
return s_instance.m_minLevel;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static Logger s_instance;
|
static Logger s_instance;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user