mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-01 16:24:12 +01:00
[dxbc] Add DxbcModuleInfo struct
This will be required in the future to pass data from the application to the shader compiler.
This commit is contained in:
parent
5d1f00be34
commit
102591369e
@ -1072,17 +1072,19 @@ namespace dxvk {
|
||||
ID3D11VertexShader** ppVertexShader) {
|
||||
InitReturnPtr(ppVertexShader);
|
||||
D3D11ShaderModule module;
|
||||
|
||||
DxbcModuleInfo moduleInfo;
|
||||
moduleInfo.options = m_dxbcOptions;
|
||||
|
||||
if (FAILED(this->CreateShaderModule(&module,
|
||||
pShaderBytecode, BytecodeLength, pClassLinkage,
|
||||
DxbcProgramType::VertexShader)))
|
||||
&moduleInfo, DxbcProgramType::VertexShader)))
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (ppVertexShader == nullptr)
|
||||
return S_FALSE;
|
||||
|
||||
*ppVertexShader = ref(new D3D11VertexShader(
|
||||
this, module));
|
||||
*ppVertexShader = ref(new D3D11VertexShader(this, module));
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -1095,16 +1097,18 @@ namespace dxvk {
|
||||
InitReturnPtr(ppGeometryShader);
|
||||
D3D11ShaderModule module;
|
||||
|
||||
DxbcModuleInfo moduleInfo;
|
||||
moduleInfo.options = m_dxbcOptions;
|
||||
|
||||
if (FAILED(this->CreateShaderModule(&module,
|
||||
pShaderBytecode, BytecodeLength, pClassLinkage,
|
||||
DxbcProgramType::GeometryShader)))
|
||||
&moduleInfo, DxbcProgramType::GeometryShader)))
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (ppGeometryShader == nullptr)
|
||||
return S_FALSE;
|
||||
|
||||
*ppGeometryShader = ref(new D3D11GeometryShader(
|
||||
this, module));
|
||||
*ppGeometryShader = ref(new D3D11GeometryShader(this, module));
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -1136,16 +1140,18 @@ namespace dxvk {
|
||||
InitReturnPtr(ppPixelShader);
|
||||
D3D11ShaderModule module;
|
||||
|
||||
DxbcModuleInfo moduleInfo;
|
||||
moduleInfo.options = m_dxbcOptions;
|
||||
|
||||
if (FAILED(this->CreateShaderModule(&module,
|
||||
pShaderBytecode, BytecodeLength, pClassLinkage,
|
||||
DxbcProgramType::PixelShader)))
|
||||
&moduleInfo, DxbcProgramType::PixelShader)))
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (ppPixelShader == nullptr)
|
||||
return S_FALSE;
|
||||
|
||||
*ppPixelShader = ref(new D3D11PixelShader(
|
||||
this, module));
|
||||
*ppPixelShader = ref(new D3D11PixelShader(this, module));
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -1158,16 +1164,18 @@ namespace dxvk {
|
||||
InitReturnPtr(ppHullShader);
|
||||
D3D11ShaderModule module;
|
||||
|
||||
DxbcModuleInfo moduleInfo;
|
||||
moduleInfo.options = m_dxbcOptions;
|
||||
|
||||
if (FAILED(this->CreateShaderModule(&module,
|
||||
pShaderBytecode, BytecodeLength, pClassLinkage,
|
||||
DxbcProgramType::HullShader)))
|
||||
&moduleInfo, DxbcProgramType::HullShader)))
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (ppHullShader == nullptr)
|
||||
return S_FALSE;
|
||||
|
||||
*ppHullShader = ref(new D3D11HullShader(
|
||||
this, module));
|
||||
*ppHullShader = ref(new D3D11HullShader(this, module));
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -1180,16 +1188,18 @@ namespace dxvk {
|
||||
InitReturnPtr(ppDomainShader);
|
||||
D3D11ShaderModule module;
|
||||
|
||||
DxbcModuleInfo moduleInfo;
|
||||
moduleInfo.options = m_dxbcOptions;
|
||||
|
||||
if (FAILED(this->CreateShaderModule(&module,
|
||||
pShaderBytecode, BytecodeLength, pClassLinkage,
|
||||
DxbcProgramType::DomainShader)))
|
||||
&moduleInfo, DxbcProgramType::DomainShader)))
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (ppDomainShader == nullptr)
|
||||
return S_FALSE;
|
||||
|
||||
*ppDomainShader = ref(new D3D11DomainShader(
|
||||
this, module));
|
||||
*ppDomainShader = ref(new D3D11DomainShader(this, module));
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -1202,16 +1212,18 @@ namespace dxvk {
|
||||
InitReturnPtr(ppComputeShader);
|
||||
D3D11ShaderModule module;
|
||||
|
||||
DxbcModuleInfo moduleInfo;
|
||||
moduleInfo.options = m_dxbcOptions;
|
||||
|
||||
if (FAILED(this->CreateShaderModule(&module,
|
||||
pShaderBytecode, BytecodeLength, pClassLinkage,
|
||||
DxbcProgramType::ComputeShader)))
|
||||
&moduleInfo, DxbcProgramType::ComputeShader)))
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (ppComputeShader == nullptr)
|
||||
return S_FALSE;
|
||||
|
||||
*ppComputeShader = ref(new D3D11ComputeShader(
|
||||
this, module));
|
||||
*ppComputeShader = ref(new D3D11ComputeShader(this, module));
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -1838,13 +1850,14 @@ namespace dxvk {
|
||||
const void* pShaderBytecode,
|
||||
size_t BytecodeLength,
|
||||
ID3D11ClassLinkage* pClassLinkage,
|
||||
const DxbcModuleInfo* pModuleInfo,
|
||||
DxbcProgramType ProgramType) {
|
||||
if (pClassLinkage != nullptr)
|
||||
Logger::warn("D3D11Device::CreateShaderModule: Class linkage not supported");
|
||||
|
||||
try {
|
||||
*pShaderModule = m_shaderModules.GetShaderModule(
|
||||
&m_dxbcOptions, pShaderBytecode, BytecodeLength, ProgramType);
|
||||
pModuleInfo, pShaderBytecode, BytecodeLength, ProgramType);
|
||||
return S_OK;
|
||||
} catch (const DxvkError& e) {
|
||||
Logger::err(e.message());
|
||||
|
@ -374,6 +374,7 @@ namespace dxvk {
|
||||
const void* pShaderBytecode,
|
||||
size_t BytecodeLength,
|
||||
ID3D11ClassLinkage* pClassLinkage,
|
||||
const DxbcModuleInfo* pModuleInfo,
|
||||
DxbcProgramType ProgramType);
|
||||
|
||||
void InitBuffer(
|
||||
|
@ -40,7 +40,7 @@ namespace dxvk {
|
||||
|
||||
D3D11ShaderModule::D3D11ShaderModule(
|
||||
const D3D11ShaderKey* pShaderKey,
|
||||
const DxbcOptions* pDxbcOptions,
|
||||
const DxbcModuleInfo* pDxbcModuleInfo,
|
||||
const void* pShaderBytecode,
|
||||
size_t BytecodeLength)
|
||||
: m_name(pShaderKey->GetName()) {
|
||||
@ -62,7 +62,7 @@ namespace dxvk {
|
||||
std::ios_base::binary | std::ios_base::trunc));
|
||||
}
|
||||
|
||||
m_shader = module.compile(*pDxbcOptions, m_name);
|
||||
m_shader = module.compile(*pDxbcModuleInfo, m_name);
|
||||
m_shader->setDebugName(m_name);
|
||||
|
||||
if (dumpPath.size() != 0) {
|
||||
@ -92,7 +92,7 @@ namespace dxvk {
|
||||
|
||||
|
||||
D3D11ShaderModule D3D11ShaderModuleSet::GetShaderModule(
|
||||
const DxbcOptions* pDxbcOptions,
|
||||
const DxbcModuleInfo* pDxbcModuleInfo,
|
||||
const void* pShaderBytecode,
|
||||
size_t BytecodeLength,
|
||||
DxbcProgramType ProgramType) {
|
||||
@ -108,7 +108,7 @@ namespace dxvk {
|
||||
|
||||
// This shader has not been compiled yet, so we have to create a
|
||||
// new module. This takes a while, so we won't lock the structure.
|
||||
D3D11ShaderModule module(&key, pDxbcOptions, pShaderBytecode, BytecodeLength);
|
||||
D3D11ShaderModule module(&key, pDxbcModuleInfo, pShaderBytecode, BytecodeLength);
|
||||
|
||||
// Insert the new module into the lookup table. If another thread
|
||||
// has compiled the same shader in the meantime, we should return
|
||||
|
@ -70,7 +70,7 @@ namespace dxvk {
|
||||
D3D11ShaderModule();
|
||||
D3D11ShaderModule(
|
||||
const D3D11ShaderKey* pShaderKey,
|
||||
const DxbcOptions* pDxbcOptions,
|
||||
const DxbcModuleInfo* pDxbcModuleInfo,
|
||||
const void* pShaderBytecode,
|
||||
size_t BytecodeLength);
|
||||
~D3D11ShaderModule();
|
||||
@ -165,7 +165,7 @@ namespace dxvk {
|
||||
~D3D11ShaderModuleSet();
|
||||
|
||||
D3D11ShaderModule GetShaderModule(
|
||||
const DxbcOptions* pDxbcOptions,
|
||||
const DxbcModuleInfo* pDxbcModuleInfo,
|
||||
const void* pShaderBytecode,
|
||||
size_t BytecodeLength,
|
||||
DxbcProgramType ProgramType);
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace dxvk {
|
||||
|
||||
DxbcAnalyzer::DxbcAnalyzer(
|
||||
const DxbcOptions& options,
|
||||
const DxbcModuleInfo& moduleInfo,
|
||||
const DxbcProgramVersion& version,
|
||||
const Rc<DxbcIsgn>& isgn,
|
||||
const Rc<DxbcIsgn>& osgn,
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "dxbc_decoder.h"
|
||||
#include "dxbc_defs.h"
|
||||
#include "dxbc_names.h"
|
||||
#include "dxbc_options.h"
|
||||
#include "dxbc_modinfo.h"
|
||||
#include "dxbc_util.h"
|
||||
|
||||
namespace dxvk {
|
||||
@ -54,7 +54,7 @@ namespace dxvk {
|
||||
public:
|
||||
|
||||
DxbcAnalyzer(
|
||||
const DxbcOptions& options,
|
||||
const DxbcModuleInfo& moduleInfo,
|
||||
const DxbcProgramVersion& version,
|
||||
const Rc<DxbcIsgn>& isgn,
|
||||
const Rc<DxbcIsgn>& osgn,
|
||||
|
@ -10,16 +10,16 @@ namespace dxvk {
|
||||
|
||||
DxbcCompiler::DxbcCompiler(
|
||||
const std::string& fileName,
|
||||
const DxbcOptions& options,
|
||||
const DxbcModuleInfo& moduleInfo,
|
||||
const DxbcProgramVersion& version,
|
||||
const Rc<DxbcIsgn>& isgn,
|
||||
const Rc<DxbcIsgn>& osgn,
|
||||
const DxbcAnalysisInfo& analysis)
|
||||
: m_options (options),
|
||||
m_version (version),
|
||||
m_isgn (isgn),
|
||||
m_osgn (osgn),
|
||||
m_analysis(&analysis) {
|
||||
: m_moduleInfo(moduleInfo),
|
||||
m_version (version),
|
||||
m_isgn (isgn),
|
||||
m_osgn (osgn),
|
||||
m_analysis (&analysis) {
|
||||
// Declare an entry point ID. We'll need it during the
|
||||
// initialization phase where the execution mode is set.
|
||||
m_entryPointId = m_module.allocateId();
|
||||
@ -791,7 +791,7 @@ namespace dxvk {
|
||||
const bool isUav = ins.op == DxbcOpcode::DclUavTyped;
|
||||
|
||||
if (isUav) {
|
||||
if (m_options.test(DxbcOption::UseStorageImageReadWithoutFormat))
|
||||
if (m_moduleInfo.options.test(DxbcOption::UseStorageImageReadWithoutFormat))
|
||||
m_module.enableCapability(spv::CapabilityStorageImageReadWithoutFormat);
|
||||
m_module.enableCapability(spv::CapabilityStorageImageWriteWithoutFormat);
|
||||
}
|
||||
@ -852,7 +852,7 @@ namespace dxvk {
|
||||
if (isUav) {
|
||||
if ((m_analysis->uavInfos[registerId].accessAtomicOp)
|
||||
|| (m_analysis->uavInfos[registerId].accessTypedLoad
|
||||
&& !m_options.test(DxbcOption::UseStorageImageReadWithoutFormat)))
|
||||
&& !m_moduleInfo.options.test(DxbcOption::UseStorageImageReadWithoutFormat)))
|
||||
imageFormat = getScalarImageFormat(sampledType);
|
||||
}
|
||||
|
||||
@ -5834,7 +5834,7 @@ namespace dxvk {
|
||||
|
||||
// We may have to defer kill operations to the end of
|
||||
// the shader in order to keep derivatives correct.
|
||||
if (m_analysis->usesKill && m_analysis->usesDerivatives && m_options.test(DxbcOption::DeferKill)) {
|
||||
if (m_analysis->usesKill && m_analysis->usesDerivatives && m_moduleInfo.options.test(DxbcOption::DeferKill)) {
|
||||
m_ps.killState = m_module.newVarInit(
|
||||
m_module.defPointerType(m_module.defBoolType(), spv::StorageClassPrivate),
|
||||
spv::StorageClassPrivate, m_module.constBool(false));
|
||||
|
@ -9,8 +9,8 @@
|
||||
#include "dxbc_chunk_isgn.h"
|
||||
#include "dxbc_decoder.h"
|
||||
#include "dxbc_defs.h"
|
||||
#include "dxbc_modinfo.h"
|
||||
#include "dxbc_names.h"
|
||||
#include "dxbc_options.h"
|
||||
#include "dxbc_util.h"
|
||||
|
||||
namespace dxvk {
|
||||
@ -354,7 +354,7 @@ namespace dxvk {
|
||||
|
||||
DxbcCompiler(
|
||||
const std::string& fileName,
|
||||
const DxbcOptions& options,
|
||||
const DxbcModuleInfo& moduleInfo,
|
||||
const DxbcProgramVersion& version,
|
||||
const Rc<DxbcIsgn>& isgn,
|
||||
const Rc<DxbcIsgn>& osgn,
|
||||
@ -376,7 +376,7 @@ namespace dxvk {
|
||||
|
||||
private:
|
||||
|
||||
DxbcOptions m_options;
|
||||
DxbcModuleInfo m_moduleInfo;
|
||||
DxbcProgramVersion m_version;
|
||||
SpirvModule m_module;
|
||||
|
||||
|
17
src/dxbc/dxbc_modinfo.h
Normal file
17
src/dxbc/dxbc_modinfo.h
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "dxbc_options.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
/**
|
||||
* \brief Shader module info
|
||||
*
|
||||
* Stores information which may affect shader compilation.
|
||||
* This data can be supplied by the client API implementation.
|
||||
*/
|
||||
struct DxbcModuleInfo {
|
||||
DxbcOptions options;
|
||||
};
|
||||
|
||||
}
|
@ -42,14 +42,14 @@ namespace dxvk {
|
||||
|
||||
|
||||
Rc<DxvkShader> DxbcModule::compile(
|
||||
const DxbcOptions& options,
|
||||
const std::string& fileName) const {
|
||||
const DxbcModuleInfo& moduleInfo,
|
||||
const std::string& fileName) const {
|
||||
if (m_shexChunk == nullptr)
|
||||
throw DxvkError("DxbcModule::compile: No SHDR/SHEX chunk");
|
||||
|
||||
DxbcAnalysisInfo analysisInfo;
|
||||
|
||||
DxbcAnalyzer analyzer(options,
|
||||
DxbcAnalyzer analyzer(moduleInfo,
|
||||
m_shexChunk->version(),
|
||||
m_isgnChunk, m_osgnChunk,
|
||||
analysisInfo);
|
||||
@ -57,7 +57,7 @@ namespace dxvk {
|
||||
this->runAnalyzer(analyzer, m_shexChunk->slice());
|
||||
|
||||
DxbcCompiler compiler(
|
||||
fileName, options,
|
||||
fileName, moduleInfo,
|
||||
m_shexChunk->version(),
|
||||
m_isgnChunk, m_osgnChunk,
|
||||
analysisInfo);
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "dxbc_chunk_isgn.h"
|
||||
#include "dxbc_chunk_shex.h"
|
||||
#include "dxbc_header.h"
|
||||
#include "dxbc_options.h"
|
||||
#include "dxbc_modinfo.h"
|
||||
#include "dxbc_reader.h"
|
||||
|
||||
// References used for figuring out DXBC:
|
||||
@ -51,14 +51,14 @@ namespace dxvk {
|
||||
/**
|
||||
* \brief Compiles DXBC shader to SPIR-V module
|
||||
*
|
||||
* \param [in] options DXBC compiler options
|
||||
* \param [in] moduleInfo DXBC module info
|
||||
* \param [in] fileName File name, will be added to
|
||||
* the compiled SPIR-V for debugging purposes.
|
||||
* \returns The compiled shader object
|
||||
*/
|
||||
Rc<DxvkShader> compile(
|
||||
const DxbcOptions& options,
|
||||
const std::string& fileName) const;
|
||||
const DxbcModuleInfo& moduleInfo,
|
||||
const std::string& fileName) const;
|
||||
|
||||
private:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user