Skeleton SPIRV shader translator.
This commit is contained in:
@@ -27,19 +27,25 @@ namespace xe {
|
||||
namespace gpu {
|
||||
|
||||
int shader_compiler_main(const std::vector<std::wstring>& args) {
|
||||
bool is_vertex_shader = false;
|
||||
ShaderType shader_type;
|
||||
if (!FLAGS_shader_type.empty()) {
|
||||
if (FLAGS_shader_type == "vs") {
|
||||
is_vertex_shader = false;
|
||||
if (FLAGS_shader_type == "vert") {
|
||||
shader_type = ShaderType::kVertex;
|
||||
} else if (FLAGS_shader_type == "frag") {
|
||||
shader_type = ShaderType::kPixel;
|
||||
} else {
|
||||
XELOGE("Invalid --shader_type; must be 'vert' or 'frag'.");
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
auto last_dot = FLAGS_input_shader.find_last_of('.');
|
||||
bool valid_type = false;
|
||||
if (last_dot != std::string::npos) {
|
||||
if (FLAGS_input_shader.substr(last_dot) == ".vert") {
|
||||
is_vertex_shader = true;
|
||||
shader_type = ShaderType::kVertex;
|
||||
valid_type = true;
|
||||
} else if (FLAGS_input_shader.substr(last_dot) == ".frag") {
|
||||
shader_type = ShaderType::kPixel;
|
||||
valid_type = true;
|
||||
}
|
||||
}
|
||||
@@ -64,11 +70,17 @@ int shader_compiler_main(const std::vector<std::wstring>& args) {
|
||||
fclose(input_file);
|
||||
|
||||
XELOGI("Opened %s as a %s shader, %" PRId64 " words (%" PRId64 " bytes).",
|
||||
FLAGS_input_shader.c_str(), is_vertex_shader ? "vertex" : "fragment",
|
||||
FLAGS_input_shader.c_str(),
|
||||
shader_type == ShaderType::kVertex ? "vertex" : "fragment",
|
||||
ucode_words.size(), ucode_words.size() * 4);
|
||||
|
||||
ShaderTranslator translator;
|
||||
|
||||
// TODO(benvanik): hash? need to return the data to big-endian format first.
|
||||
uint64_t ucode_data_hash = 0;
|
||||
auto translated_shader = translator.Translate(
|
||||
shader_type, ucode_data_hash, ucode_words.data(), ucode_words.size());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user