2017-10-16 17:50:09 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../dxvk/dxvk_shader.h"
|
|
|
|
|
2017-11-01 00:01:40 +01:00
|
|
|
#include "dxbc_chunk_isgn.h"
|
2017-10-16 17:50:09 +02:00
|
|
|
#include "dxbc_chunk_shex.h"
|
|
|
|
#include "dxbc_header.h"
|
2018-06-23 17:14:35 +02:00
|
|
|
#include "dxbc_modinfo.h"
|
2017-10-16 17:50:09 +02:00
|
|
|
#include "dxbc_reader.h"
|
|
|
|
|
|
|
|
// References used for figuring out DXBC:
|
|
|
|
// - https://github.com/tgjones/slimshader-cpp
|
|
|
|
// - Wine
|
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
|
2018-03-22 20:01:57 +01:00
|
|
|
class DxbcAnalyzer;
|
|
|
|
class DxbcCompiler;
|
|
|
|
|
2017-10-16 17:50:09 +02:00
|
|
|
/**
|
|
|
|
* \brief DXBC shader module
|
|
|
|
*
|
|
|
|
* Reads the DXBC byte code and extracts information
|
|
|
|
* about the resource bindings and the instruction
|
|
|
|
* stream. A module can then be compiled to SPIR-V.
|
|
|
|
*/
|
|
|
|
class DxbcModule {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
DxbcModule(DxbcReader& reader);
|
|
|
|
~DxbcModule();
|
|
|
|
|
2017-12-06 18:54:01 +01:00
|
|
|
/**
|
2018-10-08 09:22:58 +02:00
|
|
|
* \brief Shader type
|
|
|
|
* \returns Shader type
|
2017-12-06 18:54:01 +01:00
|
|
|
*/
|
2018-10-08 09:34:56 +02:00
|
|
|
DxbcProgramInfo programInfo() const {
|
|
|
|
return m_shexChunk->programInfo();
|
2017-12-06 18:54:01 +01:00
|
|
|
}
|
|
|
|
|
2017-12-07 12:45:02 +01:00
|
|
|
/**
|
|
|
|
* \brief Input and output signature chunks
|
|
|
|
*
|
|
|
|
* Parts of the D3D11 API need access to the
|
|
|
|
* input or output signature of the shader.
|
|
|
|
*/
|
|
|
|
Rc<DxbcIsgn> isgn() const { return m_isgnChunk; }
|
|
|
|
Rc<DxbcIsgn> osgn() const { return m_osgnChunk; }
|
|
|
|
|
2017-10-16 17:50:09 +02:00
|
|
|
/**
|
|
|
|
* \brief Compiles DXBC shader to SPIR-V module
|
2018-01-07 20:05:27 +01:00
|
|
|
*
|
2018-06-23 17:14:35 +02:00
|
|
|
* \param [in] moduleInfo DXBC module info
|
2018-04-15 21:00:08 +02:00
|
|
|
* \param [in] fileName File name, will be added to
|
|
|
|
* the compiled SPIR-V for debugging purposes.
|
2017-12-08 18:14:05 +01:00
|
|
|
* \returns The compiled shader object
|
2017-10-16 17:50:09 +02:00
|
|
|
*/
|
2018-04-15 21:00:08 +02:00
|
|
|
Rc<DxvkShader> compile(
|
2018-06-23 17:14:35 +02:00
|
|
|
const DxbcModuleInfo& moduleInfo,
|
|
|
|
const std::string& fileName) const;
|
2017-10-16 17:50:09 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2018-04-15 21:00:08 +02:00
|
|
|
DxbcHeader m_header;
|
2017-10-16 17:50:09 +02:00
|
|
|
|
2017-11-01 00:01:40 +01:00
|
|
|
Rc<DxbcIsgn> m_isgnChunk;
|
|
|
|
Rc<DxbcIsgn> m_osgnChunk;
|
2017-10-16 17:50:09 +02:00
|
|
|
Rc<DxbcShex> m_shexChunk;
|
|
|
|
|
2018-03-22 20:01:57 +01:00
|
|
|
void runAnalyzer(
|
|
|
|
DxbcAnalyzer& analyzer,
|
|
|
|
DxbcCodeSlice slice) const;
|
|
|
|
|
|
|
|
void runCompiler(
|
|
|
|
DxbcCompiler& compiler,
|
|
|
|
DxbcCodeSlice slice) const;
|
|
|
|
|
2017-10-16 17:50:09 +02:00
|
|
|
};
|
|
|
|
|
2018-10-08 09:34:56 +02:00
|
|
|
}
|