Add uniform structure
This commit is contained in:
Родитель
bafde4e917
Коммит
989563ad3f
|
@ -2393,8 +2393,8 @@ SPIREntryPoint &Compiler::get_entry_point()
|
|||
bool Compiler::interface_variable_exists_in_entry_point(uint32_t id) const
|
||||
{
|
||||
auto &var = get<SPIRVariable>(id);
|
||||
if (var.storage != StorageClassInput && var.storage != StorageClassOutput)
|
||||
throw CompilerError("Only Input and Output variables are part of a shader linking interface.");
|
||||
if (var.storage != StorageClassInput && var.storage != StorageClassOutput && var.storage != StorageClassUniformConstant)
|
||||
throw CompilerError("Only Input, Output variables and Uniform constants are part of a shader linking interface.");
|
||||
|
||||
// This is to avoid potential problems with very old glslang versions which did
|
||||
// not emit input/output interfaces properly.
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#include <algorithm>
|
||||
#include <numeric>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace spv;
|
||||
using namespace spirv_cross;
|
||||
using namespace std;
|
||||
|
@ -285,8 +287,9 @@ void CompilerMSL::add_interface_structs()
|
|||
if (var_id)
|
||||
stage_in_var_ids.push_back(var_id);
|
||||
}
|
||||
|
||||
|
||||
stage_out_var_id = add_interface_struct(StorageClassOutput);
|
||||
stage_uniforms_var_id = add_interface_struct(StorageClassUniformConstant); // TODO: use StorageClassUniform
|
||||
}
|
||||
|
||||
// Iterate through the variables and populates each input vertex attribute variable
|
||||
|
@ -409,6 +412,10 @@ uint32_t CompilerMSL::add_interface_struct(StorageClass storage, uint32_t vtx_bi
|
|||
blk.return_value = ib_var_id;
|
||||
}
|
||||
}
|
||||
|
||||
if (storage == StorageClassUniformConstant) {
|
||||
ib_var_ref = stage_uniform_var_name;
|
||||
}
|
||||
|
||||
set_name(ib_type_id, get_entry_point_name() + "_" + ib_var_ref);
|
||||
set_name(ib_var_id, ib_var_ref);
|
||||
|
@ -573,6 +580,9 @@ void CompilerMSL::emit_resources()
|
|||
emit_interface_block(stage_out_var_id);
|
||||
|
||||
// TODO: Consolidate and output loose uniforms into an input struct
|
||||
|
||||
emit_interface_block(stage_uniforms_var_id);
|
||||
|
||||
}
|
||||
|
||||
// Override for MSL-specific syntax instructions
|
||||
|
|
|
@ -155,9 +155,11 @@ protected:
|
|||
std::unordered_map<uint32_t, uint32_t> pad_type_ids_by_pad_len;
|
||||
std::vector<uint32_t> stage_in_var_ids;
|
||||
uint32_t stage_out_var_id = 0;
|
||||
uint32_t stage_uniforms_var_id = 0;
|
||||
std::string qual_pos_var_name;
|
||||
std::string stage_in_var_name = "in";
|
||||
std::string stage_out_var_name = "out";
|
||||
std::string stage_uniform_var_name = "uniforms";
|
||||
std::string sampler_name_suffix = "Smplr";
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче