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

View File

@ -363,11 +363,11 @@ namespace dxvk {
void DxvkGraphicsPipeline::logPipelineState( void DxvkGraphicsPipeline::logPipelineState(
LogLevel level, LogLevel level,
const DxvkGraphicsPipelineStateInfo& state) const { const DxvkGraphicsPipelineStateInfo& state) const {
if (m_vs != nullptr) Logger::log(level, str::format(" vs : ", m_vs ->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->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->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 ->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 ->debugName())); if (m_fs != nullptr) Logger::log(level, str::format(" fs : ", m_fs ->shader()->debugName()));
// TODO log more pipeline state // TODO log more pipeline state
} }

View File

@ -4,10 +4,9 @@ namespace dxvk {
DxvkShaderModule::DxvkShaderModule( DxvkShaderModule::DxvkShaderModule(
const Rc<vk::DeviceFn>& vkd, const Rc<vk::DeviceFn>& vkd,
VkShaderStageFlagBits stage, const Rc<DxvkShader>& shader,
const SpirvCodeBuffer& code, const SpirvCodeBuffer& code)
const std::string& name) : m_vkd(vkd), m_shader(shader) {
: 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;
@ -32,7 +31,7 @@ namespace dxvk {
info.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; info.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
info.pNext = nullptr; info.pNext = nullptr;
info.flags = 0; info.flags = 0;
info.stage = m_stage; info.stage = m_shader->stage();
info.module = m_module; info.module = m_module;
info.pName = "main"; info.pName = "main";
info.pSpecializationInfo = specInfo; info.pSpecializationInfo = specInfo;
@ -95,7 +94,7 @@ namespace dxvk {
Rc<DxvkShaderModule> DxvkShader::createShaderModule( Rc<DxvkShaderModule> DxvkShader::createShaderModule(
const Rc<vk::DeviceFn>& vkd, const Rc<vk::DeviceFn>& vkd,
const DxvkDescriptorSlotMapping& mapping) const { const DxvkDescriptorSlotMapping& mapping) {
SpirvCodeBuffer spirvCode = m_code; SpirvCodeBuffer spirvCode = m_code;
// Remap resource binding IDs // Remap resource binding IDs
@ -103,7 +102,7 @@ namespace dxvk {
for (uint32_t ofs : m_idOffsets) for (uint32_t ofs : m_idOffsets)
code[ofs] = mapping.getBindingId(code[ofs]); 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 { namespace dxvk {
class DxvkShader;
/** /**
* \brief Shader interface slots * \brief Shader interface slots
* *
@ -36,9 +38,8 @@ namespace dxvk {
DxvkShaderModule( DxvkShaderModule(
const Rc<vk::DeviceFn>& vkd, const Rc<vk::DeviceFn>& vkd,
VkShaderStageFlagBits stage, const Rc<DxvkShader>& shader,
const SpirvCodeBuffer& code, const SpirvCodeBuffer& code);
const std::string& name);
~DxvkShaderModule(); ~DxvkShaderModule();
@ -60,19 +61,18 @@ namespace dxvk {
const VkSpecializationInfo* specInfo) const; const VkSpecializationInfo* specInfo) const;
/** /**
* \brief The shader's debug name * \brief Shader object
* \returns Debug name * \returns The shader
*/ */
const std::string& debugName() const { Rc<DxvkShader> shader() const {
return m_debugName; return m_shader;
} }
private: private:
Rc<vk::DeviceFn> m_vkd; Rc<vk::DeviceFn> m_vkd;
VkShaderStageFlagBits m_stage; Rc<DxvkShader> m_shader;
VkShaderModule m_module; VkShaderModule m_module;
std::string m_debugName;
}; };
@ -98,6 +98,14 @@ namespace dxvk {
~DxvkShader(); ~DxvkShader();
/**
* \brief Shader stage
* \returns Shader stage
*/
VkShaderStageFlagBits stage() const {
return m_stage;
}
/** /**
* \brief Checks whether a capability is enabled * \brief Checks whether a capability is enabled
* *
@ -130,7 +138,7 @@ namespace dxvk {
*/ */
Rc<DxvkShaderModule> createShaderModule( Rc<DxvkShaderModule> createShaderModule(
const Rc<vk::DeviceFn>& vkd, const Rc<vk::DeviceFn>& vkd,
const DxvkDescriptorSlotMapping& mapping) const; const DxvkDescriptorSlotMapping& mapping);
/** /**
* \brief Inter-stage interface slots * \brief Inter-stage interface slots
@ -159,6 +167,16 @@ namespace dxvk {
*/ */
void read(std::istream& inputStream); 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 * \brief Sets the shader's debug name
* *
@ -171,13 +189,11 @@ namespace dxvk {
} }
/** /**
* \brief Shader hash * \brief Retrieves debug name
* * \returns The shader's name
* The SHA-1 hash of the generated SPIR-V shader.
* \returns SHA-1 hash of this shader
*/ */
Sha1Hash hash() const { std::string debugName() const {
return m_hash; return m_debugName;
} }
private: private: