CompilerMSL vectorless constructor uses vectorless attribute and resource bindings.

This commit is contained in:
Bill Hollings 2017-04-04 16:38:17 -04:00
parent 9bad477f16
commit 7703b746f7
2 changed files with 18 additions and 17 deletions

View File

@ -27,7 +27,9 @@ using namespace std;
static const uint32_t k_unknown_location = ~0;
void CompilerMSL::init(vector<MSLVertexAttr> *p_vtx_attrs, vector<MSLResourceBinding> *p_res_bindings)
CompilerMSL::CompilerMSL(vector<uint32_t> spirv_, vector<MSLVertexAttr> *p_vtx_attrs,
vector<MSLResourceBinding> *p_res_bindings)
: CompilerGLSL(move(spirv_))
{
populate_func_name_overrides();
populate_var_name_overrides();
@ -41,18 +43,20 @@ void CompilerMSL::init(vector<MSLVertexAttr> *p_vtx_attrs, vector<MSLResourceBin
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)
CompilerMSL::CompilerMSL(const uint32_t *ir, size_t word_count, MSLVertexAttr *p_vtx_attrs, size_t vtx_attrs_count,
MSLResourceBinding *p_res_bindings, size_t res_bindings_count)
: CompilerGLSL(ir, word_count)
{
init(p_vtx_attrs, p_res_bindings);
populate_func_name_overrides();
populate_var_name_overrides();
if (p_vtx_attrs)
for (size_t i = 0; i < vtx_attrs_count; i++)
vtx_attrs_by_location[p_vtx_attrs[i].location] = &p_vtx_attrs[i];
if (p_res_bindings)
for (size_t i = 0; i < res_bindings_count; i++)
resource_bindings.push_back(&p_res_bindings[i]);
}
// Populate the collection of function names that need to be overridden
@ -1863,7 +1867,6 @@ string CompilerMSL::type_to_glsl(const SPIRType &type)
return image_type_glsl(type);
case SPIRType::Sampler:
// Not really used.
return "sampler";
case SPIRType::Void:

View File

@ -106,8 +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);
// Alternate constructor avoiding use of std::vectors.
CompilerMSL(const uint32_t *ir, size_t word_count, MSLVertexAttr *p_vtx_attrs = nullptr, size_t vtx_attrs_count = 0,
MSLResourceBinding *p_res_bindings = nullptr, size_t res_bindings_count = 0);
// Compiles the SPIR-V code into Metal Shading Language.
std::string compile() override;
@ -252,9 +253,6 @@ protected:
Meta &meta;
SortAspect sort_aspect;
};
private:
void init(std::vector<MSLVertexAttr> *p_vtx_attrs, std::vector<MSLResourceBinding> *p_res_bindings);
};
}