mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-15 07:29:17 +01:00
[d3d11] Added shader module creation log
This commit is contained in:
parent
a0fafe3043
commit
3fc064f434
@ -12,51 +12,42 @@ namespace dxvk {
|
|||||||
D3D11Device* pDevice,
|
D3D11Device* pDevice,
|
||||||
const void* pShaderBytecode,
|
const void* pShaderBytecode,
|
||||||
size_t BytecodeLength) {
|
size_t BytecodeLength) {
|
||||||
|
|
||||||
DxbcReader reader(
|
DxbcReader reader(
|
||||||
reinterpret_cast<const char*>(pShaderBytecode),
|
reinterpret_cast<const char*>(pShaderBytecode),
|
||||||
BytecodeLength);
|
BytecodeLength);
|
||||||
|
|
||||||
DxbcModule module(reader);
|
DxbcModule module(reader);
|
||||||
|
|
||||||
|
// Construct the shader name that we'll use for
|
||||||
|
// debug messages and as the dump/read file name
|
||||||
|
m_name = ConstructFileName(
|
||||||
|
ComputeShaderHash(pShaderBytecode, BytecodeLength),
|
||||||
|
module.version().type());
|
||||||
|
|
||||||
|
Logger::debug(str::format("Compiling shader ", m_name));
|
||||||
|
|
||||||
// If requested by the user, dump both the raw DXBC
|
// If requested by the user, dump both the raw DXBC
|
||||||
// shader and the compiled SPIR-V module to a file.
|
// shader and the compiled SPIR-V module to a file.
|
||||||
const std::string dumpPath
|
const std::string dumpPath = env::getEnvVar(L"DXVK_SHADER_DUMP_PATH");
|
||||||
= env::getEnvVar(L"DXVK_SHADER_DUMP_PATH");
|
const std::string readPath = env::getEnvVar(L"DXVK_SHADER_READ_PATH");
|
||||||
|
|
||||||
if (dumpPath.size() != 0) {
|
if (dumpPath.size() != 0) {
|
||||||
const std::string baseName = str::format(dumpPath, "/",
|
reader.store(std::ofstream(str::format(dumpPath, "/", m_name, ".dxbc"),
|
||||||
ConstructFileName(ComputeShaderHash(pShaderBytecode, BytecodeLength),
|
|
||||||
module.version().type()));
|
|
||||||
|
|
||||||
reader.store(std::ofstream(str::format(baseName, ".dxbc"),
|
|
||||||
std::ios_base::binary | std::ios_base::trunc));
|
std::ios_base::binary | std::ios_base::trunc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_shader = module.compile(*pDxbcOptions);
|
m_shader = module.compile(*pDxbcOptions);
|
||||||
|
|
||||||
if (dumpPath.size() != 0) {
|
if (dumpPath.size() != 0) {
|
||||||
const std::string baseName = str::format(dumpPath, "/",
|
m_shader->dump(std::ofstream(str::format(dumpPath, "/", m_name, ".spv"),
|
||||||
ConstructFileName(ComputeShaderHash(pShaderBytecode, BytecodeLength),
|
|
||||||
module.version().type()));
|
|
||||||
|
|
||||||
m_shader->dump(std::ofstream(str::format(baseName, ".spv"),
|
|
||||||
std::ios_base::binary | std::ios_base::trunc));
|
std::ios_base::binary | std::ios_base::trunc));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If requested by the user, replace
|
// If requested by the user, replace
|
||||||
// the shader with another file.
|
// the shader with another file.
|
||||||
const std::string readPath
|
|
||||||
= env::getEnvVar(L"DXVK_SHADER_READ_PATH");
|
|
||||||
|
|
||||||
if (readPath.size() != 0) {
|
if (readPath.size() != 0) {
|
||||||
const std::string baseName = str::format(readPath, "/",
|
|
||||||
ConstructFileName(ComputeShaderHash(pShaderBytecode, BytecodeLength),
|
|
||||||
module.version().type()));
|
|
||||||
|
|
||||||
m_shader->read(std::ifstream(
|
m_shader->read(std::ifstream(
|
||||||
str::format(baseName, ".spv"),
|
str::format(readPath, "/", m_name, ".spv"),
|
||||||
std::ios_base::binary));
|
std::ios_base::binary));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,7 +65,6 @@ namespace dxvk {
|
|||||||
std::string D3D11ShaderModule::ConstructFileName(
|
std::string D3D11ShaderModule::ConstructFileName(
|
||||||
const Sha1Hash& hash,
|
const Sha1Hash& hash,
|
||||||
const DxbcProgramType& type) const {
|
const DxbcProgramType& type) const {
|
||||||
|
|
||||||
std::string typeStr;
|
std::string typeStr;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -37,6 +37,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
std::string m_name;
|
||||||
Rc<DxvkShader> m_shader;
|
Rc<DxvkShader> m_shader;
|
||||||
|
|
||||||
Sha1Hash ComputeShaderHash(
|
Sha1Hash ComputeShaderHash(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user