From 16caa10697e7bdafcd647266fa253065cc3f9640 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 22 Mar 2018 20:01:57 +0100 Subject: [PATCH] [dxbc] Add analyzer stub Will be used to gather information for the compiler. --- src/dxbc/dxbc_analysis.cpp | 22 ++++++++++++++++ src/dxbc/dxbc_analysis.h | 51 ++++++++++++++++++++++++++++++++++++++ src/dxbc/dxbc_module.cpp | 30 +++++++++++++++++++--- src/dxbc/dxbc_module.h | 11 ++++++++ src/dxbc/meson.build | 1 + 5 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 src/dxbc/dxbc_analysis.cpp create mode 100644 src/dxbc/dxbc_analysis.h diff --git a/src/dxbc/dxbc_analysis.cpp b/src/dxbc/dxbc_analysis.cpp new file mode 100644 index 000000000..697a80d60 --- /dev/null +++ b/src/dxbc/dxbc_analysis.cpp @@ -0,0 +1,22 @@ +#include "dxbc_analysis.h" + +namespace dxvk { + + DxbcAnalyzer::DxbcAnalyzer( + const DxbcOptions& options, + const DxbcProgramVersion& version) { + + } + + + DxbcAnalyzer::~DxbcAnalyzer() { + + } + + + void DxbcAnalyzer::processInstruction( + const DxbcShaderInstruction& ins) { + + } + +} \ No newline at end of file diff --git a/src/dxbc/dxbc_analysis.h b/src/dxbc/dxbc_analysis.h new file mode 100644 index 000000000..cb22a2587 --- /dev/null +++ b/src/dxbc/dxbc_analysis.h @@ -0,0 +1,51 @@ +#pragma once + +#include "dxbc_chunk_isgn.h" +#include "dxbc_decoder.h" +#include "dxbc_defs.h" +#include "dxbc_names.h" +#include "dxbc_options.h" +#include "dxbc_util.h" + +namespace dxvk { + + struct DxbcUavInfo { + bool accessTypedRead = false; + bool accessAtomicOp = false; + }; + + struct DxbcAnalysisInfo { + std::array uavInfos; + }; + + /** + * \brief DXBC shader analysis pass + * + * Collects information about the shader itself + * and the resources used by the shader, which + * will later be used by the actual compiler. + */ + class DxbcAnalyzer { + + public: + + DxbcAnalyzer( + const DxbcOptions& options, + const DxbcProgramVersion& version); + + ~DxbcAnalyzer(); + + /** + * \brief Processes a single instruction + * \param [in] ins The instruction + */ + void processInstruction( + const DxbcShaderInstruction& ins); + + private: + + + + }; + +} \ No newline at end of file diff --git a/src/dxbc/dxbc_module.cpp b/src/dxbc/dxbc_module.cpp index 792022fa4..f48b5ef93 100644 --- a/src/dxbc/dxbc_module.cpp +++ b/src/dxbc/dxbc_module.cpp @@ -1,3 +1,4 @@ +#include "dxbc_analysis.h" #include "dxbc_compiler.h" #include "dxbc_module.h" @@ -44,12 +45,37 @@ namespace dxvk { if (m_shexChunk == nullptr) throw DxvkError("DxbcModule::compile: No SHDR/SHEX chunk"); - DxbcCodeSlice slice = m_shexChunk->slice(); + DxbcAnalyzer analyzer(options, + m_shexChunk->version()); DxbcCompiler compiler(options, m_shexChunk->version(), m_isgnChunk, m_osgnChunk); + this->runAnalyzer(analyzer, m_shexChunk->slice()); + this->runCompiler(compiler, m_shexChunk->slice()); + + return compiler.finalize(); + } + + + void DxbcModule::runAnalyzer( + DxbcAnalyzer& analyzer, + DxbcCodeSlice slice) const { + DxbcDecodeContext decoder; + + while (!slice.atEnd()) { + decoder.decodeInstruction(slice); + + analyzer.processInstruction( + decoder.getInstruction()); + } + } + + + void DxbcModule::runCompiler( + DxbcCompiler& compiler, + DxbcCodeSlice slice) const { DxbcDecodeContext decoder; while (!slice.atEnd()) { @@ -58,8 +84,6 @@ namespace dxvk { compiler.processInstruction( decoder.getInstruction()); } - - return compiler.finalize(); } } \ No newline at end of file diff --git a/src/dxbc/dxbc_module.h b/src/dxbc/dxbc_module.h index d4a8ef76b..c4a792369 100644 --- a/src/dxbc/dxbc_module.h +++ b/src/dxbc/dxbc_module.h @@ -14,6 +14,9 @@ namespace dxvk { + class DxbcAnalyzer; + class DxbcCompiler; + /** * \brief DXBC shader module * @@ -61,6 +64,14 @@ namespace dxvk { Rc m_osgnChunk; Rc m_shexChunk; + void runAnalyzer( + DxbcAnalyzer& analyzer, + DxbcCodeSlice slice) const; + + void runCompiler( + DxbcCompiler& compiler, + DxbcCodeSlice slice) const; + }; } \ No newline at end of file diff --git a/src/dxbc/meson.build b/src/dxbc/meson.build index c44a2b1ad..63e2dea9d 100644 --- a/src/dxbc/meson.build +++ b/src/dxbc/meson.build @@ -1,4 +1,5 @@ dxbc_src = files([ + 'dxbc_analysis.cpp', 'dxbc_chunk_isgn.cpp', 'dxbc_chunk_shex.cpp', 'dxbc_common.cpp',