1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-11-30 04:24:11 +01:00

[dxvk] Make shader accessible from shader module

This commit is contained in:
Philip Rebohle 2018-05-03 20:26:55 +02:00
parent 33357f1f36
commit ae0e5bccdd
4 changed files with 45 additions and 30 deletions

View File

@ -96,7 +96,7 @@ namespace dxvk {
if (Logger::logLevel() <= LogLevel::Debug) {
Logger::debug("Compiling compute pipeline...");
Logger::debug(str::format(" cs : ", m_cs ->debugName()));
Logger::debug(str::format(" cs : ", m_cs->shader()->debugName()));
}
std::array<VkBool32, MaxNumActiveBindings> specData;
@ -131,7 +131,7 @@ namespace dxvk {
if (m_vkd->vkCreateComputePipelines(m_vkd->device(),
m_cache->handle(), 1, &info, nullptr, &pipeline) != VK_SUCCESS) {
Logger::err("DxvkComputePipeline: Failed to compile pipeline");
Logger::err(str::format(" cs : ", m_cs ->debugName()));
Logger::err(str::format(" cs : ", m_cs->shader()->debugName()));
return VK_NULL_HANDLE;
}

View File

@ -363,11 +363,11 @@ namespace dxvk {
void DxvkGraphicsPipeline::logPipelineState(
LogLevel level,
const DxvkGraphicsPipelineStateInfo& state) const {
if (m_vs != nullptr) Logger::log(level, str::format(" vs : ", m_vs ->debugName()));
if (m_tcs != nullptr) Logger::log(level, str::format(" tcs : ", m_tcs->debugName()));
if (m_tes != nullptr) Logger::log(level, str::format(" tes : ", m_tes->debugName()));
if (m_gs != nullptr) Logger::log(level, str::format(" gs : ", m_gs ->debugName()));
if (m_fs != nullptr) Logger::log(level, str::format(" fs : ", m_fs ->debugName()));
if (m_vs != nullptr) Logger::log(level, str::format(" vs : ", m_vs ->shader()->debugName()));
if (m_tcs != nullptr) Logger::log(level, str::format(" tcs : ", m_tcs->shader()->debugName()));
if (m_tes != nullptr) Logger::log(level, str::format(" tes : ", m_tes->shader()->debugName()));
if (m_gs != nullptr) Logger::log(level, str::format(" gs : ", m_gs ->shader()->debugName()));
if (m_fs != nullptr) Logger::log(level, str::format(" fs : ", m_fs ->shader()->debugName()));
// TODO log more pipeline state
}

View File

@ -4,10 +4,9 @@ namespace dxvk {
DxvkShaderModule::DxvkShaderModule(
const Rc<vk::DeviceFn>& vkd,
VkShaderStageFlagBits stage,
const SpirvCodeBuffer& code,
const std::string& name)
: m_vkd(vkd), m_stage(stage), m_debugName(name) {
const Rc<DxvkShader>& shader,
const SpirvCodeBuffer& code)
: m_vkd(vkd), m_shader(shader) {
VkShaderModuleCreateInfo info;
info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
info.pNext = nullptr;
@ -32,7 +31,7 @@ namespace dxvk {
info.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
info.pNext = nullptr;
info.flags = 0;
info.stage = m_stage;
info.stage = m_shader->stage();
info.module = m_module;
info.pName = "main";
info.pSpecializationInfo = specInfo;
@ -95,7 +94,7 @@ namespace dxvk {
Rc<DxvkShaderModule> DxvkShader::createShaderModule(
const Rc<vk::DeviceFn>& vkd,
const DxvkDescriptorSlotMapping& mapping) const {
const DxvkDescriptorSlotMapping& mapping) {
SpirvCodeBuffer spirvCode = m_code;
// Remap resource binding IDs
@ -103,7 +102,7 @@ namespace dxvk {
for (uint32_t ofs : m_idOffsets)
code[ofs] = mapping.getBindingId(code[ofs]);
return new DxvkShaderModule(vkd, m_stage, spirvCode, m_debugName);
return new DxvkShaderModule(vkd, this, spirvCode);
}

View File

@ -9,6 +9,8 @@
namespace dxvk {
class DxvkShader;
/**
* \brief Shader interface slots
*
@ -36,9 +38,8 @@ namespace dxvk {
DxvkShaderModule(
const Rc<vk::DeviceFn>& vkd,
VkShaderStageFlagBits stage,
const SpirvCodeBuffer& code,
const std::string& name);
const Rc<DxvkShader>& shader,
const SpirvCodeBuffer& code);
~DxvkShaderModule();
@ -60,19 +61,18 @@ namespace dxvk {
const VkSpecializationInfo* specInfo) const;
/**
* \brief The shader's debug name
* \returns Debug name
* \brief Shader object
* \returns The shader
*/
const std::string& debugName() const {
return m_debugName;
Rc<DxvkShader> shader() const {
return m_shader;
}
private:
Rc<vk::DeviceFn> m_vkd;
VkShaderStageFlagBits m_stage;
Rc<DxvkShader> m_shader;
VkShaderModule m_module;
std::string m_debugName;
};
@ -98,6 +98,14 @@ namespace dxvk {
~DxvkShader();
/**
* \brief Shader stage
* \returns Shader stage
*/
VkShaderStageFlagBits stage() const {
return m_stage;
}
/**
* \brief Checks whether a capability is enabled
*
@ -130,7 +138,7 @@ namespace dxvk {
*/
Rc<DxvkShaderModule> createShaderModule(
const Rc<vk::DeviceFn>& vkd,
const DxvkDescriptorSlotMapping& mapping) const;
const DxvkDescriptorSlotMapping& mapping);
/**
* \brief Inter-stage interface slots
@ -159,6 +167,16 @@ namespace dxvk {
*/
void read(std::istream& inputStream);
/**
* \brief Shader hash
*
* The SHA-1 hash of the generated SPIR-V shader.
* \returns SHA-1 hash of this shader
*/
Sha1Hash hash() const {
return m_hash;
}
/**
* \brief Sets the shader's debug name
*
@ -171,13 +189,11 @@ namespace dxvk {
}
/**
* \brief Shader hash
*
* The SHA-1 hash of the generated SPIR-V shader.
* \returns SHA-1 hash of this shader
* \brief Retrieves debug name
* \returns The shader's name
*/
Sha1Hash hash() const {
return m_hash;
std::string debugName() const {
return m_debugName;
}
private: