Add vector-less IR construction to subclasses as well.

This commit is contained in:
Hans-Kristian Arntzen 2017-04-01 16:08:19 +02:00
parent 46f4695fb7
commit 9bad477f16
5 changed files with 49 additions and 8 deletions

View File

@ -30,6 +30,12 @@ public:
: CompilerGLSL(move(spirv_))
{
}
CompilerCPP(const uint32_t *ir, size_t word_count)
: CompilerGLSL(ir, word_count)
{
}
std::string compile() override;
// Sets a custom symbol name that can override

View File

@ -100,11 +100,13 @@ public:
CompilerGLSL(std::vector<uint32_t> spirv_)
: Compiler(move(spirv_))
{
if (source.known)
{
options.es = source.es;
options.version = source.version;
}
init();
}
CompilerGLSL(const uint32_t *ir, size_t word_count)
: Compiler(ir, word_count)
{
init();
}
const Options &get_options() const
@ -446,6 +448,16 @@ protected:
void fixup_image_load_store_access();
bool type_is_empty(const SPIRType &type);
private:
void init()
{
if (source.known)
{
options.es = source.es;
options.version = source.version;
}
}
};
}

View File

@ -38,6 +38,11 @@ public:
{
}
CompilerHLSL(const uint32_t *ir, size_t size)
: CompilerGLSL(ir, size)
{
}
const Options &get_options() const
{
return options;

View File

@ -27,9 +27,7 @@ using namespace std;
static const uint32_t k_unknown_location = ~0;
CompilerMSL::CompilerMSL(vector<uint32_t> spirv_, vector<MSLVertexAttr> *p_vtx_attrs,
vector<MSLResourceBinding> *p_res_bindings)
: CompilerGLSL(move(spirv_))
void CompilerMSL::init(vector<MSLVertexAttr> *p_vtx_attrs, vector<MSLResourceBinding> *p_res_bindings)
{
populate_func_name_overrides();
populate_var_name_overrides();
@ -43,6 +41,20 @@ CompilerMSL::CompilerMSL(vector<uint32_t> spirv_, vector<MSLVertexAttr> *p_vtx_a
resource_bindings.push_back(&rb);
}
CompilerMSL::CompilerMSL(vector<uint32_t> spirv_, vector<MSLVertexAttr> *p_vtx_attrs,
vector<MSLResourceBinding> *p_res_bindings)
: CompilerGLSL(move(spirv_))
{
init(p_vtx_attrs, p_res_bindings);
}
CompilerMSL::CompilerMSL(const uint32_t *ir, size_t word_count, vector<MSLVertexAttr> *p_vtx_attrs,
vector<MSLResourceBinding> *p_res_bindings)
: CompilerGLSL(ir, word_count)
{
init(p_vtx_attrs, p_res_bindings);
}
// Populate the collection of function names that need to be overridden
void CompilerMSL::populate_func_name_overrides()
{

View File

@ -106,6 +106,9 @@ public:
CompilerMSL(std::vector<uint32_t> spirv, std::vector<MSLVertexAttr> *p_vtx_attrs = nullptr,
std::vector<MSLResourceBinding> *p_res_bindings = nullptr);
CompilerMSL(const uint32_t *ir, size_t word_count, std::vector<MSLVertexAttr> *p_vtx_attrs = nullptr,
std::vector<MSLResourceBinding> *p_res_bindings = nullptr);
// Compiles the SPIR-V code into Metal Shading Language.
std::string compile() override;
@ -249,6 +252,9 @@ protected:
Meta &meta;
SortAspect sort_aspect;
};
private:
void init(std::vector<MSLVertexAttr> *p_vtx_attrs, std::vector<MSLResourceBinding> *p_res_bindings);
};
}