Rework API graphique Vulkan - EnTT pour ECS + Chargement modèle 3D assimp + SDL3 pour events input et fenetre + mesh texture camera transform ok + attention tous les assets nouveaus ne sont pas commités et il y a du code test en dur dans scene addentity + restructuration globale
This commit is contained in:
76
lib/All/SPIRV-Reflect/examples/CMakeLists.txt
Normal file
76
lib/All/SPIRV-Reflect/examples/CMakeLists.txt
Normal file
@@ -0,0 +1,76 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(examples)
|
||||
|
||||
list(APPEND SPIRV_REFLECT_FILES
|
||||
${CMAKE_SOURCE_DIR}/spirv_reflect.h
|
||||
${CMAKE_SOURCE_DIR}/spirv_reflect.c
|
||||
)
|
||||
|
||||
list(APPEND COMMON_FILES
|
||||
common.h
|
||||
common.cpp
|
||||
../common/output_stream.h
|
||||
../common/output_stream.cpp
|
||||
sample_spv.h
|
||||
)
|
||||
|
||||
################################################################################
|
||||
# descriptors
|
||||
################################################################################
|
||||
add_executable(descriptors ${CMAKE_CURRENT_SOURCE_DIR}/main_descriptors.cpp ${COMMON_FILES} ${SPIRV_REFLECT_FILES})
|
||||
target_include_directories(descriptors PRIVATE ${CMAKE_SOURCE_DIR})
|
||||
if (${VULKAN_DIR_FOUND})
|
||||
target_compile_definitions(descriptors PRIVATE SPIRV_REFLECT_HAS_VULKAN_H)
|
||||
target_include_directories(descriptors PRIVATE ${VULKAN_DIR}/include)
|
||||
set_target_properties(descriptors PROPERTIES CXX_STANDARD 11)
|
||||
endif()
|
||||
if(WIN32)
|
||||
target_compile_definitions(descriptors PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||
set_target_properties(descriptors PROPERTIES FOLDER "examples")
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
# io_variables
|
||||
################################################################################
|
||||
add_executable(io_variables ${CMAKE_CURRENT_SOURCE_DIR}/main_io_variables.cpp ${COMMON_FILES} ${SPIRV_REFLECT_FILES})
|
||||
target_include_directories(io_variables PRIVATE ${CMAKE_SOURCE_DIR})
|
||||
if (${VULKAN_DIR_FOUND})
|
||||
target_compile_definitions(io_variables PRIVATE SPIRV_REFLECT_HAS_VULKAN_H)
|
||||
target_include_directories(io_variables PRIVATE ${VULKAN_DIR}/include)
|
||||
set_target_properties(io_variables PROPERTIES CXX_STANDARD 11)
|
||||
endif()
|
||||
if(WIN32)
|
||||
target_compile_definitions(io_variables PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||
set_target_properties(io_variables PROPERTIES FOLDER "examples")
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
# hlsl_resource_types
|
||||
################################################################################
|
||||
add_executable(hlsl_resource_types ${CMAKE_CURRENT_SOURCE_DIR}/main_hlsl_resource_types.cpp ${COMMON_FILES} ${SPIRV_REFLECT_FILES})
|
||||
target_include_directories(hlsl_resource_types PRIVATE ${CMAKE_SOURCE_DIR})
|
||||
if (${VULKAN_DIR_FOUND})
|
||||
target_compile_definitions(hlsl_resource_types PRIVATE SPIRV_REFLECT_HAS_VULKAN_H)
|
||||
target_include_directories(hlsl_resource_types PRIVATE ${VULKAN_DIR}/include)
|
||||
set_target_properties(hlsl_resource_types PROPERTIES CXX_STANDARD 11)
|
||||
endif()
|
||||
if(WIN32)
|
||||
target_compile_definitions(hlsl_resource_types PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||
set_target_properties(hlsl_resource_types PROPERTIES FOLDER "examples")
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
# explorer
|
||||
################################################################################
|
||||
add_executable(explorer ${CMAKE_CURRENT_SOURCE_DIR}/main_explorer.cpp ${COMMON_FILES} ${SPIRV_REFLECT_FILES})
|
||||
target_include_directories(explorer PRIVATE ${CMAKE_SOURCE_DIR})
|
||||
if (${VULKAN_DIR_FOUND})
|
||||
target_compile_definitions(explorer PRIVATE SPIRV_REFLECT_HAS_VULKAN_H)
|
||||
target_include_directories(explorer PRIVATE ${VULKAN_DIR}/include)
|
||||
set_target_properties(explorer PROPERTIES CXX_STANDARD 11)
|
||||
endif()
|
||||
if(WIN32)
|
||||
target_compile_definitions(explorer PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||
set_target_properties(explorer PROPERTIES FOLDER "examples")
|
||||
endif()
|
||||
362
lib/All/SPIRV-Reflect/examples/arg_parser.cpp
Normal file
362
lib/All/SPIRV-Reflect/examples/arg_parser.cpp
Normal file
@@ -0,0 +1,362 @@
|
||||
#include "arg_parser.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
ArgParser::ArgParser() {}
|
||||
|
||||
ArgParser::~ArgParser() {}
|
||||
|
||||
ArgParser::Option* ArgParser::FindOptionByShortName(const std::string& short_name) {
|
||||
ArgParser::Option* p_option = nullptr;
|
||||
auto it = std::find_if(std::begin(m_options), std::end(m_options),
|
||||
[short_name](const ArgParser::Option& elem) -> bool { return elem.short_name == short_name; });
|
||||
if (it != std::end(m_options)) {
|
||||
p_option = &(*it);
|
||||
}
|
||||
return p_option;
|
||||
}
|
||||
|
||||
const ArgParser::Option* ArgParser::FindOptionByShortName(const std::string& short_name) const {
|
||||
const ArgParser::Option* p_option = nullptr;
|
||||
auto it = std::find_if(std::begin(m_options), std::end(m_options),
|
||||
[short_name](const ArgParser::Option& elem) -> bool { return elem.short_name == short_name; });
|
||||
if (it != std::end(m_options)) {
|
||||
p_option = &(*it);
|
||||
}
|
||||
return p_option;
|
||||
}
|
||||
|
||||
ArgParser::Option* ArgParser::FindOptionByLongName(const std::string& long_name) {
|
||||
ArgParser::Option* p_option = nullptr;
|
||||
auto it = std::find_if(std::begin(m_options), std::end(m_options),
|
||||
[long_name](const ArgParser::Option& elem) -> bool { return elem.long_name == long_name; });
|
||||
if (it != std::end(m_options)) {
|
||||
p_option = &(*it);
|
||||
}
|
||||
return p_option;
|
||||
}
|
||||
|
||||
const ArgParser::Option* ArgParser::FindOptionByLongName(const std::string& long_name) const {
|
||||
const ArgParser::Option* p_option = nullptr;
|
||||
auto it = std::find_if(std::begin(m_options), std::end(m_options),
|
||||
[long_name](const ArgParser::Option& elem) -> bool { return elem.long_name == long_name; });
|
||||
if (it != std::end(m_options)) {
|
||||
p_option = &(*it);
|
||||
}
|
||||
return p_option;
|
||||
}
|
||||
|
||||
bool ArgParser::AddFlag(const std::string& short_name, const std::string& long_name, const std::string& desc) {
|
||||
Option option = {};
|
||||
option.short_name = short_name;
|
||||
option.long_name = long_name;
|
||||
option.type = OPTION_TYPE_FLAG;
|
||||
option.desc = desc;
|
||||
auto p_short = FindOptionByShortName(short_name);
|
||||
auto p_long = FindOptionByLongName(long_name);
|
||||
if ((p_short != nullptr) || (p_long != nullptr)) {
|
||||
return false;
|
||||
}
|
||||
m_options.push_back(option);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ArgParser::AddOptionString(const std::string& short_name, const std::string& long_name, const std::string& desc,
|
||||
const std::string& default_value) {
|
||||
Option option = {};
|
||||
option.short_name = short_name;
|
||||
option.long_name = long_name;
|
||||
option.type = OPTION_TYPE_STRING;
|
||||
option.desc = desc;
|
||||
option.default_value.str = default_value;
|
||||
auto p_short = FindOptionByShortName(short_name);
|
||||
auto p_long = FindOptionByLongName(long_name);
|
||||
if ((p_short != nullptr) || (p_long != nullptr)) {
|
||||
return false;
|
||||
}
|
||||
m_options.push_back(option);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ArgParser::AddOptionInt(const std::string& short_name, const std::string& long_name, const std::string& desc,
|
||||
int default_value) {
|
||||
Option option = {};
|
||||
option.short_name = short_name;
|
||||
option.long_name = long_name;
|
||||
option.type = OPTION_TYPE_INT;
|
||||
option.desc = desc;
|
||||
option.default_value.i32 = default_value;
|
||||
auto p_short = FindOptionByShortName(short_name);
|
||||
auto p_long = FindOptionByLongName(long_name);
|
||||
if ((p_short != nullptr) || (p_long != nullptr)) {
|
||||
return false;
|
||||
}
|
||||
m_options.push_back(option);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ArgParser::AddOptionFloat(const std::string& short_name, const std::string& long_name, const std::string& desc,
|
||||
float default_value) {
|
||||
Option option = {};
|
||||
option.short_name = short_name;
|
||||
option.long_name = long_name;
|
||||
option.type = OPTION_TYPE_FLOAT;
|
||||
option.desc = desc;
|
||||
option.default_value.f32 = default_value;
|
||||
auto p_short = FindOptionByShortName(short_name);
|
||||
auto p_long = FindOptionByLongName(long_name);
|
||||
if ((p_short != nullptr) || (p_long != nullptr)) {
|
||||
return false;
|
||||
}
|
||||
m_options.push_back(option);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ArgParser::Parse(int argc, char** argv, std::ostream& os) {
|
||||
for (auto& opt : m_options) {
|
||||
opt.value = opt.default_value;
|
||||
opt.parsed = false;
|
||||
}
|
||||
|
||||
int i = 1;
|
||||
while (i < argc) {
|
||||
std::string s = argv[i];
|
||||
if (s[0] == '-') {
|
||||
ArgParser::Option* p_option = nullptr;
|
||||
if ((s.length() >= 2) && ((s[0] == '-') && (s[1] == '-'))) {
|
||||
std::string long_name = s.substr(2);
|
||||
p_option = FindOptionByLongName(long_name);
|
||||
} else {
|
||||
std::string short_name = s.substr(1);
|
||||
p_option = FindOptionByShortName(short_name);
|
||||
}
|
||||
|
||||
if (p_option == nullptr) {
|
||||
os << "ERROR: invalid argument " << s << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (p_option->type) {
|
||||
case OPTION_TYPE_FLAG: {
|
||||
p_option->parsed = true;
|
||||
i += 1;
|
||||
} break;
|
||||
|
||||
case OPTION_TYPE_STRING: {
|
||||
if ((i + 1) >= argc) {
|
||||
os << "ERROR: missing option data for " << s << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
s = argv[i + 1];
|
||||
p_option->value.str = s;
|
||||
p_option->parsed = true;
|
||||
|
||||
i += 2;
|
||||
} break;
|
||||
|
||||
case OPTION_TYPE_INT: {
|
||||
if ((i + 1) >= argc) {
|
||||
os << "ERROR: missing option data for " << s << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
s = argv[i + 1];
|
||||
p_option->value.i32 = atoi(s.c_str());
|
||||
p_option->parsed = true;
|
||||
|
||||
i += 2;
|
||||
} break;
|
||||
|
||||
case OPTION_TYPE_FLOAT: {
|
||||
if ((i + 1) >= argc) {
|
||||
os << "ERROR: missing option data for " << s << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
s = argv[i + 1];
|
||||
p_option->value.f32 = static_cast<float>(atof(s.c_str()));
|
||||
p_option->parsed = true;
|
||||
|
||||
i += 2;
|
||||
} break;
|
||||
|
||||
case OPTION_TYPE_UNDEFINED: {
|
||||
} break;
|
||||
}
|
||||
} else {
|
||||
m_args.push_back(s);
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t ArgParser::GetArgCount() const { return m_args.size(); }
|
||||
|
||||
bool ArgParser::GetArg(size_t i, std::string* p_value) const {
|
||||
if ((GetArgCount() == 0) && (i >= GetArgCount())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (p_value != nullptr) {
|
||||
*p_value = m_args[i];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& ArgParser::GetArgs() const { return m_args; }
|
||||
|
||||
bool ArgParser::GetFlag(const std::string& short_name, const std::string& long_name) const {
|
||||
auto p_short = FindOptionByShortName(short_name);
|
||||
auto p_long = FindOptionByLongName(long_name);
|
||||
|
||||
const ArgParser::Option* p_option = nullptr;
|
||||
if (p_short != nullptr) {
|
||||
p_option = p_short;
|
||||
}
|
||||
if ((p_option == nullptr) && (p_long != nullptr)) {
|
||||
p_option = p_short;
|
||||
}
|
||||
|
||||
if (p_option == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (p_option->type != OPTION_TYPE_FLAG) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return p_option->parsed;
|
||||
}
|
||||
|
||||
bool ArgParser::GetString(const std::string& short_name, const std::string& long_name, std::string* p_value) const {
|
||||
auto p_short = FindOptionByShortName(short_name);
|
||||
auto p_long = FindOptionByLongName(long_name);
|
||||
|
||||
const ArgParser::Option* p_option = nullptr;
|
||||
if (p_short != nullptr) {
|
||||
p_option = p_short;
|
||||
}
|
||||
if ((p_option == nullptr) && (p_long != nullptr)) {
|
||||
p_option = p_short;
|
||||
}
|
||||
|
||||
if (p_option == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!p_option->parsed || (p_option->type != OPTION_TYPE_STRING)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (p_value != nullptr) {
|
||||
*p_value = p_option->value.str;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ArgParser::GetInt(const std::string& short_name, const std::string& long_name, int* p_value) const {
|
||||
auto p_short = FindOptionByShortName(short_name);
|
||||
auto p_long = FindOptionByLongName(long_name);
|
||||
|
||||
const ArgParser::Option* p_option = nullptr;
|
||||
if (p_short != nullptr) {
|
||||
p_option = p_short;
|
||||
}
|
||||
if ((p_option == nullptr) && (p_long != nullptr)) {
|
||||
p_option = p_short;
|
||||
}
|
||||
|
||||
if (p_option == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!p_option->parsed || (p_option->type != OPTION_TYPE_INT)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (p_value != nullptr) {
|
||||
*p_value = p_option->value.i32;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ArgParser::GetFloat(const std::string& short_name, const std::string& long_name, float* p_value) const {
|
||||
auto p_short = FindOptionByShortName(short_name);
|
||||
auto p_long = FindOptionByLongName(long_name);
|
||||
|
||||
const ArgParser::Option* p_option = nullptr;
|
||||
if (p_short != nullptr) {
|
||||
p_option = p_short;
|
||||
}
|
||||
if ((p_option == nullptr) && (p_long != nullptr)) {
|
||||
p_option = p_short;
|
||||
}
|
||||
|
||||
if (p_option == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!p_option->parsed || (p_option->type != OPTION_TYPE_FLOAT)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (p_value != nullptr) {
|
||||
*p_value = p_option->value.f32;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ArgParser::PrintHelp(std::ostream& os) {
|
||||
(void)os;
|
||||
|
||||
/*
|
||||
if (m_options.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct TextLine {
|
||||
std::string option;
|
||||
std::string desc;
|
||||
};
|
||||
std::vector<TextLine> text_lines;
|
||||
|
||||
size_t max_width = 0;
|
||||
for (auto& it : m_options) {
|
||||
std::stringstream ss;
|
||||
ss << "--" << it.first;
|
||||
switch (it.second.type) {
|
||||
default: break;
|
||||
case OPTION_TYPE_STRING : ss << " " << "[s]"; break;
|
||||
case OPTION_TYPE_INT : ss << " " << "[i]"; break;
|
||||
case OPTION_TYPE_FLOAT : ss << " " << "[f]"; break;
|
||||
}
|
||||
|
||||
std::string option = ss.str();
|
||||
max_width = std::max(max_width, option.size());
|
||||
|
||||
TextLine tl;
|
||||
tl.option = option;
|
||||
tl.desc = it.second.desc;
|
||||
text_lines.push_back(tl);
|
||||
}
|
||||
max_width += 2;
|
||||
|
||||
os << "\n";
|
||||
os << "Options:" << "\n";
|
||||
for (auto& tl : text_lines) {
|
||||
os << " ";
|
||||
os << std::left << std::setw(max_width) << tl.option;
|
||||
os << tl.desc;
|
||||
os << "\n";
|
||||
}
|
||||
*/
|
||||
}
|
||||
65
lib/All/SPIRV-Reflect/examples/arg_parser.h
Normal file
65
lib/All/SPIRV-Reflect/examples/arg_parser.h
Normal file
@@ -0,0 +1,65 @@
|
||||
#ifndef __VERIFLECT_ARG_PARSER_H__
|
||||
#define __VERIFLECT_ARG_PARSER_H__
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
class ArgParser {
|
||||
public:
|
||||
enum OptionType { OPTION_TYPE_UNDEFINED = 0, OPTION_TYPE_FLAG, OPTION_TYPE_STRING, OPTION_TYPE_INT, OPTION_TYPE_FLOAT };
|
||||
|
||||
struct OptionValue {
|
||||
std::string str;
|
||||
union {
|
||||
int i32;
|
||||
float f32;
|
||||
};
|
||||
};
|
||||
|
||||
struct Option {
|
||||
std::string short_name;
|
||||
std::string long_name;
|
||||
OptionType type;
|
||||
std::string desc;
|
||||
OptionValue value;
|
||||
OptionValue default_value;
|
||||
bool parsed;
|
||||
};
|
||||
|
||||
ArgParser();
|
||||
~ArgParser();
|
||||
|
||||
bool AddFlag(const std::string& short_name, const std::string& long_name, const std::string& desc);
|
||||
bool AddOptionString(const std::string& short_name, const std::string& long_name, const std::string& desc,
|
||||
const std::string& default_value = "");
|
||||
bool AddOptionInt(const std::string& short_name, const std::string& long_name, const std::string& desc, int default_value = 0);
|
||||
bool AddOptionFloat(const std::string& short_name, const std::string& long_name, const std::string& desc,
|
||||
float default_value = 0);
|
||||
|
||||
bool Parse(int argc, char** argv, std::ostream& os);
|
||||
|
||||
size_t GetArgCount() const;
|
||||
bool GetArg(size_t i, std::string* p_value) const;
|
||||
const std::vector<std::string>& GetArgs() const;
|
||||
|
||||
bool GetFlag(const std::string& short_name, const std::string& long_name) const;
|
||||
bool GetString(const std::string& short_name, const std::string& long_name, std::string* p_value) const;
|
||||
bool GetInt(const std::string& short_name, const std::string& long_name, int* p_value) const;
|
||||
bool GetFloat(const std::string& short_name, const std::string& long_name, float* p_value) const;
|
||||
|
||||
void PrintHelp(std::ostream& os);
|
||||
|
||||
private:
|
||||
ArgParser::Option* FindOptionByShortName(const std::string& short_name);
|
||||
const ArgParser::Option* FindOptionByShortName(const std::string& short_name) const;
|
||||
ArgParser::Option* FindOptionByLongName(const std::string& long_name);
|
||||
const ArgParser::Option* FindOptionByLongName(const std::string& long_name) const;
|
||||
|
||||
private:
|
||||
std::vector<ArgParser::Option> m_options;
|
||||
std::vector<std::string> m_args;
|
||||
};
|
||||
|
||||
#endif // __VERIFLECT_ARG_PARSER_H__
|
||||
32
lib/All/SPIRV-Reflect/examples/build_sample_spv_h.sh
Normal file
32
lib/All/SPIRV-Reflect/examples/build_sample_spv_h.sh
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo -e "#ifndef SAMPLE_SPV_H" > sample_spv.h
|
||||
echo -e "#define SAMPLE_SPV_H" >> sample_spv.h
|
||||
|
||||
echo -e "" >> sample_spv.h
|
||||
echo -e "/* Source from sample.hlsl" >> sample_spv.h
|
||||
echo -e "" >> sample_spv.h
|
||||
cat sample.hlsl >> sample_spv.h
|
||||
echo -e "\n" >> sample_spv.h
|
||||
echo -e "*/" >> sample_spv.h
|
||||
|
||||
echo -e "" >> sample_spv.h
|
||||
|
||||
echo -e "// Imported from file 'sample.spv'" >> sample_spv.h
|
||||
echo -e "const uint32_t k_sample_spv[] = {" >> sample_spv.h
|
||||
glslc.exe -fshader-stage=frag -fentry-point=main -mfmt=num -o - sample.hlsl >> sample_spv.h
|
||||
echo -e "};" >> sample_spv.h
|
||||
echo -e "" >> sample_spv.h
|
||||
|
||||
echo -e "/* SPIRV Disassembly" >> sample_spv.h
|
||||
echo -e "" >> sample_spv.h
|
||||
spirv-dis --raw-id sample.spv >> sample_spv.h
|
||||
echo -e "" >> sample_spv.h
|
||||
echo -e "*/" >> sample_spv.h
|
||||
|
||||
echo -e "" >> sample_spv.h
|
||||
echo -e "#endif // SAMPLE_SPV_H" >> sample_spv.h
|
||||
|
||||
dos2unix sample_spv.h
|
||||
|
||||
rm -f tmp_sample_spv_h
|
||||
128
lib/All/SPIRV-Reflect/examples/common.cpp
Normal file
128
lib/All/SPIRV-Reflect/examples/common.cpp
Normal file
@@ -0,0 +1,128 @@
|
||||
#include "common.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include "../common/output_stream.h"
|
||||
|
||||
void PrintModuleInfo(std::ostream& os, const SpvReflectShaderModule& obj, const char* /*indent*/) {
|
||||
os << "entry point : " << obj.entry_point_name << "\n";
|
||||
os << "source lang : " << spvReflectSourceLanguage(obj.source_language) << "\n";
|
||||
os << "source lang ver : " << obj.source_language_version << "\n";
|
||||
if (obj.source_language == SpvSourceLanguageHLSL) {
|
||||
os << "stage : ";
|
||||
switch (obj.shader_stage) {
|
||||
default:
|
||||
break;
|
||||
case SPV_REFLECT_SHADER_STAGE_VERTEX_BIT:
|
||||
os << "VS";
|
||||
break;
|
||||
case SPV_REFLECT_SHADER_STAGE_TESSELLATION_CONTROL_BIT:
|
||||
os << "HS";
|
||||
break;
|
||||
case SPV_REFLECT_SHADER_STAGE_TESSELLATION_EVALUATION_BIT:
|
||||
os << "DS";
|
||||
break;
|
||||
case SPV_REFLECT_SHADER_STAGE_GEOMETRY_BIT:
|
||||
os << "GS";
|
||||
break;
|
||||
case SPV_REFLECT_SHADER_STAGE_FRAGMENT_BIT:
|
||||
os << "PS";
|
||||
break;
|
||||
case SPV_REFLECT_SHADER_STAGE_COMPUTE_BIT:
|
||||
os << "CS";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PrintDescriptorSet(std::ostream& os, const SpvReflectDescriptorSet& obj, const char* indent) {
|
||||
const char* t = indent;
|
||||
std::string tt = std::string(indent) + " ";
|
||||
std::string ttttt = std::string(indent) + " ";
|
||||
|
||||
os << t << "set : " << obj.set << "\n";
|
||||
os << t << "binding count : " << obj.binding_count;
|
||||
os << "\n";
|
||||
for (uint32_t i = 0; i < obj.binding_count; ++i) {
|
||||
const SpvReflectDescriptorBinding& binding = *obj.bindings[i];
|
||||
os << tt << i << ":"
|
||||
<< "\n";
|
||||
PrintDescriptorBinding(os, binding, false, ttttt.c_str());
|
||||
if (i < (obj.binding_count - 1)) {
|
||||
os << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PrintDescriptorBinding(std::ostream& os, const SpvReflectDescriptorBinding& obj, bool write_set, const char* indent) {
|
||||
const char* t = indent;
|
||||
os << t << "binding : " << obj.binding << "\n";
|
||||
if (write_set) {
|
||||
os << t << "set : " << obj.set << "\n";
|
||||
}
|
||||
os << t << "type : " << ToStringDescriptorType(obj.descriptor_type) << "\n";
|
||||
|
||||
// array
|
||||
if (obj.array.dims_count > 0) {
|
||||
os << t << "array : ";
|
||||
for (uint32_t dim_index = 0; dim_index < obj.array.dims_count; ++dim_index) {
|
||||
os << "[" << obj.array.dims[dim_index] << "]";
|
||||
}
|
||||
os << "\n";
|
||||
}
|
||||
|
||||
// counter
|
||||
if (obj.uav_counter_binding != nullptr) {
|
||||
os << t << "counter : ";
|
||||
os << "(";
|
||||
os << "set=" << obj.uav_counter_binding->set << ", ";
|
||||
os << "binding=" << obj.uav_counter_binding->binding << ", ";
|
||||
os << "name=" << obj.uav_counter_binding->name;
|
||||
os << ");";
|
||||
os << "\n";
|
||||
}
|
||||
|
||||
os << t << "name : " << obj.name;
|
||||
if ((obj.type_description->type_name != nullptr) && (strlen(obj.type_description->type_name) > 0)) {
|
||||
os << " "
|
||||
<< "(" << obj.type_description->type_name << ")";
|
||||
}
|
||||
}
|
||||
|
||||
void PrintInterfaceVariable(std::ostream& os, SpvSourceLanguage src_lang, const SpvReflectInterfaceVariable& obj,
|
||||
const char* indent) {
|
||||
const char* t = indent;
|
||||
os << t << "location : ";
|
||||
if (obj.decoration_flags & SPV_REFLECT_DECORATION_BUILT_IN) {
|
||||
os << ToStringSpvBuiltIn(obj, true);
|
||||
} else {
|
||||
os << obj.location;
|
||||
}
|
||||
os << "\n";
|
||||
if (obj.semantic != nullptr) {
|
||||
os << t << "semantic : " << obj.semantic << "\n";
|
||||
}
|
||||
os << t << "type : " << ToStringType(src_lang, *obj.type_description) << "\n";
|
||||
os << t << "format : " << ToStringFormat(obj.format) << "\n";
|
||||
os << t << "qualifier : ";
|
||||
if (obj.decoration_flags & SPV_REFLECT_DECORATION_FLAT) {
|
||||
os << "flat";
|
||||
} else if (obj.decoration_flags & SPV_REFLECT_DECORATION_NOPERSPECTIVE) {
|
||||
os << "noperspective";
|
||||
} else if (obj.decoration_flags & SPV_REFLECT_DECORATION_PATCH) {
|
||||
os << "patch";
|
||||
} else if (obj.decoration_flags & SPV_REFLECT_DECORATION_PER_VERTEX) {
|
||||
os << "pervertex";
|
||||
} else if (obj.decoration_flags & SPV_REFLECT_DECORATION_PER_TASK) {
|
||||
os << "pertask";
|
||||
}
|
||||
os << "\n";
|
||||
|
||||
os << t << "name : " << obj.name;
|
||||
if ((obj.type_description->type_name != nullptr) && (strlen(obj.type_description->type_name) > 0)) {
|
||||
os << " "
|
||||
<< "(" << obj.type_description->type_name << ")";
|
||||
}
|
||||
}
|
||||
14
lib/All/SPIRV-Reflect/examples/common.h
Normal file
14
lib/All/SPIRV-Reflect/examples/common.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef SPIRV_REFLECT_EXAMPLES_COMMON_H
|
||||
#define SPIRV_REFLECT_EXAMPLES_COMMON_H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "spirv_reflect.h"
|
||||
|
||||
void PrintModuleInfo(std::ostream& os, const SpvReflectShaderModule& obj, const char* indent = "");
|
||||
void PrintDescriptorSet(std::ostream& os, const SpvReflectDescriptorSet& obj, const char* indent = "");
|
||||
void PrintDescriptorBinding(std::ostream& os, const SpvReflectDescriptorBinding& obj, bool write_set, const char* indent = "");
|
||||
void PrintInterfaceVariable(std::ostream& os, SpvSourceLanguage src_lang, const SpvReflectInterfaceVariable& obj,
|
||||
const char* indent);
|
||||
|
||||
#endif
|
||||
85
lib/All/SPIRV-Reflect/examples/main_descriptors.cpp
Normal file
85
lib/All/SPIRV-Reflect/examples/main_descriptors.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
#include <cassert>
|
||||
|
||||
#include "common.h"
|
||||
#include "sample_spv.h"
|
||||
|
||||
#if defined(SPIRV_REFLECT_HAS_VULKAN_H)
|
||||
#include <vulkan/vulkan.h>
|
||||
struct DescriptorSetLayoutData {
|
||||
uint32_t set_number;
|
||||
VkDescriptorSetLayoutCreateInfo create_info;
|
||||
std::vector<VkDescriptorSetLayoutBinding> bindings;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main(int argn, char** argv) {
|
||||
SpvReflectShaderModule module = {};
|
||||
SpvReflectResult result = spvReflectCreateShaderModule(sizeof(k_sample_spv), k_sample_spv, &module);
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
|
||||
uint32_t count = 0;
|
||||
result = spvReflectEnumerateDescriptorSets(&module, &count, NULL);
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
|
||||
std::vector<SpvReflectDescriptorSet*> sets(count);
|
||||
result = spvReflectEnumerateDescriptorSets(&module, &count, sets.data());
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
|
||||
#if defined(SPIRV_REFLECT_HAS_VULKAN_H)
|
||||
// Demonstrates how to generate all necessary data structures to create a
|
||||
// VkDescriptorSetLayout for each descriptor set in this shader.
|
||||
std::vector<DescriptorSetLayoutData> set_layouts(sets.size(), DescriptorSetLayoutData{});
|
||||
for (size_t i_set = 0; i_set < sets.size(); ++i_set) {
|
||||
const SpvReflectDescriptorSet& refl_set = *(sets[i_set]);
|
||||
DescriptorSetLayoutData& layout = set_layouts[i_set];
|
||||
layout.bindings.resize(refl_set.binding_count);
|
||||
for (uint32_t i_binding = 0; i_binding < refl_set.binding_count; ++i_binding) {
|
||||
const SpvReflectDescriptorBinding& refl_binding = *(refl_set.bindings[i_binding]);
|
||||
VkDescriptorSetLayoutBinding& layout_binding = layout.bindings[i_binding];
|
||||
layout_binding.binding = refl_binding.binding;
|
||||
layout_binding.descriptorType = static_cast<VkDescriptorType>(refl_binding.descriptor_type);
|
||||
layout_binding.descriptorCount = 1;
|
||||
for (uint32_t i_dim = 0; i_dim < refl_binding.array.dims_count; ++i_dim) {
|
||||
layout_binding.descriptorCount *= refl_binding.array.dims[i_dim];
|
||||
}
|
||||
layout_binding.stageFlags = static_cast<VkShaderStageFlagBits>(module.shader_stage);
|
||||
}
|
||||
layout.set_number = refl_set.set;
|
||||
layout.create_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
||||
layout.create_info.bindingCount = refl_set.binding_count;
|
||||
layout.create_info.pBindings = layout.bindings.data();
|
||||
}
|
||||
// Nothing further is done with set_layouts in this sample; in a real
|
||||
// application they would be merged with similar structures from other shader
|
||||
// stages and/or pipelines to create a VkPipelineLayout.
|
||||
#endif
|
||||
|
||||
// Log the descriptor set contents to stdout
|
||||
const char* t = " ";
|
||||
const char* tt = " ";
|
||||
|
||||
PrintModuleInfo(std::cout, module);
|
||||
std::cout << "\n\n";
|
||||
|
||||
std::cout << "Descriptor sets:"
|
||||
<< "\n";
|
||||
for (size_t index = 0; index < sets.size(); ++index) {
|
||||
auto p_set = sets[index];
|
||||
|
||||
// descriptor sets can also be retrieved directly from the module, by set
|
||||
// index
|
||||
auto p_set2 = spvReflectGetDescriptorSet(&module, p_set->set, &result);
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
assert(p_set == p_set2);
|
||||
(void)p_set2;
|
||||
|
||||
std::cout << t << index << ":"
|
||||
<< "\n";
|
||||
PrintDescriptorSet(std::cout, *p_set, tt);
|
||||
std::cout << "\n\n";
|
||||
}
|
||||
|
||||
spvReflectDestroyShaderModule(&module);
|
||||
|
||||
return 0;
|
||||
}
|
||||
104
lib/All/SPIRV-Reflect/examples/main_explorer.cpp
Normal file
104
lib/All/SPIRV-Reflect/examples/main_explorer.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
/* Copyright (c) 2023 LunarG, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include "spirv_reflect.h"
|
||||
|
||||
// =================================================================================================
|
||||
// PrintUsage()
|
||||
// =================================================================================================
|
||||
void PrintUsage() {
|
||||
std::cout << "Usage: explorer path/to/SPIR-V/bytecode.spv\n"
|
||||
<< "\tThis is used to set a breakpoint and explorer the API and "
|
||||
"how to access info needed\n";
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
// main()
|
||||
// =================================================================================================
|
||||
int main(int argn, char** argv) {
|
||||
if (argn != 2) {
|
||||
PrintUsage();
|
||||
return EXIT_FAILURE;
|
||||
} else if (std::string(argv[1]) == "--help") {
|
||||
PrintUsage();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
std::string input_spv_path = argv[1];
|
||||
|
||||
std::ifstream spv_ifstream(input_spv_path.c_str(), std::ios::binary);
|
||||
if (!spv_ifstream.is_open()) {
|
||||
std::cerr << "ERROR: could not open '" << input_spv_path << "' for reading\n";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
spv_ifstream.seekg(0, std::ios::end);
|
||||
size_t size = static_cast<size_t>(spv_ifstream.tellg());
|
||||
spv_ifstream.seekg(0, std::ios::beg);
|
||||
|
||||
std::vector<char> spv_data(size);
|
||||
spv_ifstream.read(spv_data.data(), size);
|
||||
|
||||
SpvReflectShaderModule module = {};
|
||||
SpvReflectResult result = spvReflectCreateShaderModule(spv_data.size(), spv_data.data(), &module);
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
|
||||
// Go through each enumerate to examine it
|
||||
uint32_t count = 0;
|
||||
|
||||
result = spvReflectEnumerateDescriptorSets(&module, &count, NULL);
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
std::vector<SpvReflectDescriptorSet*> sets(count);
|
||||
result = spvReflectEnumerateDescriptorSets(&module, &count, sets.data());
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
|
||||
result = spvReflectEnumerateDescriptorBindings(&module, &count, NULL);
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
std::vector<SpvReflectDescriptorBinding*> bindings(count);
|
||||
result = spvReflectEnumerateDescriptorBindings(&module, &count, bindings.data());
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
|
||||
result = spvReflectEnumerateInterfaceVariables(&module, &count, NULL);
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
std::vector<SpvReflectInterfaceVariable*> interface_variables(count);
|
||||
result = spvReflectEnumerateInterfaceVariables(&module, &count, interface_variables.data());
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
|
||||
result = spvReflectEnumerateInputVariables(&module, &count, NULL);
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
std::vector<SpvReflectInterfaceVariable*> input_variables(count);
|
||||
result = spvReflectEnumerateInputVariables(&module, &count, input_variables.data());
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
result = spvReflectEnumerateOutputVariables(&module, &count, NULL);
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
std::vector<SpvReflectInterfaceVariable*> output_variables(count);
|
||||
result = spvReflectEnumerateOutputVariables(&module, &count, output_variables.data());
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
|
||||
result = spvReflectEnumeratePushConstantBlocks(&module, &count, NULL);
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
std::vector<SpvReflectBlockVariable*> push_constant(count);
|
||||
result = spvReflectEnumeratePushConstantBlocks(&module, &count, push_constant.data());
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
|
||||
// Can set a breakpoint here and explorer the various variables enumerated.
|
||||
spvReflectDestroyShaderModule(&module);
|
||||
|
||||
return 0;
|
||||
}
|
||||
149
lib/All/SPIRV-Reflect/examples/main_hlsl_resource_types.cpp
Normal file
149
lib/All/SPIRV-Reflect/examples/main_hlsl_resource_types.cpp
Normal file
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
Copyright 2017-2018 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined(WIN32)
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <crtdbg.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#include "../common/output_stream.h"
|
||||
#include "examples/common.h"
|
||||
#include "spirv_reflect.h"
|
||||
|
||||
void StreamWrite(std::ostream& os, const SpvReflectDescriptorBinding& obj, bool write_set, const char* indent = "") {
|
||||
const char* t = indent;
|
||||
|
||||
os << " " << obj.name;
|
||||
os << "\n";
|
||||
os << t;
|
||||
os << ToStringDescriptorType(obj.descriptor_type);
|
||||
os << " "
|
||||
<< "(" << ToStringResourceType(obj.resource_type) << ")";
|
||||
if ((obj.descriptor_type == SPV_REFLECT_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
|
||||
(obj.descriptor_type == SPV_REFLECT_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
|
||||
(obj.descriptor_type == SPV_REFLECT_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
|
||||
(obj.descriptor_type == SPV_REFLECT_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
|
||||
os << "\n";
|
||||
os << t;
|
||||
os << "dim=" << obj.image.dim << ", ";
|
||||
os << "depth=" << obj.image.depth << ", ";
|
||||
os << "arrayed=" << obj.image.arrayed << ", ";
|
||||
os << "ms=" << obj.image.ms << ", ";
|
||||
os << "sampled=" << obj.image.sampled;
|
||||
}
|
||||
}
|
||||
|
||||
void StreamWrite(std::ostream& os, const SpvReflectShaderModule& obj, const char* indent = "") {
|
||||
os << "entry point : " << obj.entry_point_name << "\n";
|
||||
os << "source lang : " << spvReflectSourceLanguage(obj.source_language) << "\n";
|
||||
os << "source lang ver : " << obj.source_language_version;
|
||||
}
|
||||
|
||||
void StreamWrite(std::ostream& os, const SpvReflectDescriptorBinding& obj) { StreamWrite(os, obj, true, " "); }
|
||||
|
||||
// Specialized stream-writer that only includes descriptor bindings.
|
||||
void StreamWrite(std::ostream& os, const spv_reflect::ShaderModule& obj) {
|
||||
const char* t = " ";
|
||||
const char* tt = " ";
|
||||
const char* ttt = " ";
|
||||
|
||||
StreamWrite(os, obj.GetShaderModule(), "");
|
||||
|
||||
SpvReflectResult result = SPV_REFLECT_RESULT_NOT_READY;
|
||||
uint32_t count = 0;
|
||||
std::vector<SpvReflectInterfaceVariable*> variables;
|
||||
std::vector<SpvReflectDescriptorBinding*> bindings;
|
||||
std::vector<SpvReflectDescriptorSet*> sets;
|
||||
|
||||
count = 0;
|
||||
result = obj.EnumerateDescriptorBindings(&count, nullptr);
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
bindings.resize(count);
|
||||
result = obj.EnumerateDescriptorBindings(&count, bindings.data());
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
if (count > 0) {
|
||||
os << "\n";
|
||||
os << "\n";
|
||||
os << t << "Descriptor bindings: " << count << "\n";
|
||||
for (size_t i = 0; i < bindings.size(); ++i) {
|
||||
auto p_binding = bindings[i];
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
os << tt << i << ":";
|
||||
StreamWrite(os, *p_binding, true, ttt);
|
||||
if (i < (count - 1)) {
|
||||
os << "\n\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
// PrintUsage()
|
||||
// =================================================================================================
|
||||
void PrintUsage() {
|
||||
std::cout << "Usage: hlsl_resource_types [OPTIONS] path/to/SPIR-V/bytecode.spv" << std::endl
|
||||
<< "Options:" << std::endl
|
||||
<< " --help: Display this message" << std::endl
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
// main()
|
||||
// =================================================================================================
|
||||
int main(int argn, char** argv) {
|
||||
if (argn != 2) {
|
||||
PrintUsage();
|
||||
return EXIT_FAILURE;
|
||||
} else if (std::string(argv[1]) == "--help") {
|
||||
PrintUsage();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
std::string input_spv_path = argv[1];
|
||||
|
||||
std::ifstream spv_ifstream(input_spv_path.c_str(), std::ios::binary);
|
||||
if (!spv_ifstream.is_open()) {
|
||||
std::cerr << "ERROR: could not open '" << input_spv_path << "' for reading" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
spv_ifstream.seekg(0, std::ios::end);
|
||||
size_t size = static_cast<size_t>(spv_ifstream.tellg());
|
||||
spv_ifstream.seekg(0, std::ios::beg);
|
||||
|
||||
{
|
||||
std::vector<char> spv_data(size);
|
||||
spv_ifstream.read(spv_data.data(), size);
|
||||
|
||||
spv_reflect::ShaderModule reflection(spv_data.size(), spv_data.data());
|
||||
if (reflection.GetResult() != SPV_REFLECT_RESULT_SUCCESS) {
|
||||
std::cerr << "ERROR: could not process '" << input_spv_path << "' (is it a valid SPIR-V bytecode?)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
StreamWrite(std::cout, reflection);
|
||||
std::cout << std::endl << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
557
lib/All/SPIRV-Reflect/examples/main_io_variables.cpp
Normal file
557
lib/All/SPIRV-Reflect/examples/main_io_variables.cpp
Normal file
@@ -0,0 +1,557 @@
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "common.h"
|
||||
#include "sample_spv.h"
|
||||
|
||||
#if defined(SPIRV_REFLECT_HAS_VULKAN_H)
|
||||
#include <vulkan/vulkan.h>
|
||||
// Returns the size in bytes of the provided VkFormat.
|
||||
// As this is only intended for vertex attribute formats, not all VkFormats are
|
||||
// supported.
|
||||
static uint32_t FormatSize(VkFormat format) {
|
||||
uint32_t result = 0;
|
||||
switch (format) {
|
||||
case VK_FORMAT_UNDEFINED:
|
||||
result = 0;
|
||||
break;
|
||||
case VK_FORMAT_R4G4_UNORM_PACK8:
|
||||
result = 1;
|
||||
break;
|
||||
case VK_FORMAT_R4G4B4A4_UNORM_PACK16:
|
||||
result = 2;
|
||||
break;
|
||||
case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
|
||||
result = 2;
|
||||
break;
|
||||
case VK_FORMAT_R5G6B5_UNORM_PACK16:
|
||||
result = 2;
|
||||
break;
|
||||
case VK_FORMAT_B5G6R5_UNORM_PACK16:
|
||||
result = 2;
|
||||
break;
|
||||
case VK_FORMAT_R5G5B5A1_UNORM_PACK16:
|
||||
result = 2;
|
||||
break;
|
||||
case VK_FORMAT_B5G5R5A1_UNORM_PACK16:
|
||||
result = 2;
|
||||
break;
|
||||
case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
|
||||
result = 2;
|
||||
break;
|
||||
case VK_FORMAT_R8_UNORM:
|
||||
result = 1;
|
||||
break;
|
||||
case VK_FORMAT_R8_SNORM:
|
||||
result = 1;
|
||||
break;
|
||||
case VK_FORMAT_R8_USCALED:
|
||||
result = 1;
|
||||
break;
|
||||
case VK_FORMAT_R8_SSCALED:
|
||||
result = 1;
|
||||
break;
|
||||
case VK_FORMAT_R8_UINT:
|
||||
result = 1;
|
||||
break;
|
||||
case VK_FORMAT_R8_SINT:
|
||||
result = 1;
|
||||
break;
|
||||
case VK_FORMAT_R8_SRGB:
|
||||
result = 1;
|
||||
break;
|
||||
case VK_FORMAT_R8G8_UNORM:
|
||||
result = 2;
|
||||
break;
|
||||
case VK_FORMAT_R8G8_SNORM:
|
||||
result = 2;
|
||||
break;
|
||||
case VK_FORMAT_R8G8_USCALED:
|
||||
result = 2;
|
||||
break;
|
||||
case VK_FORMAT_R8G8_SSCALED:
|
||||
result = 2;
|
||||
break;
|
||||
case VK_FORMAT_R8G8_UINT:
|
||||
result = 2;
|
||||
break;
|
||||
case VK_FORMAT_R8G8_SINT:
|
||||
result = 2;
|
||||
break;
|
||||
case VK_FORMAT_R8G8_SRGB:
|
||||
result = 2;
|
||||
break;
|
||||
case VK_FORMAT_R8G8B8_UNORM:
|
||||
result = 3;
|
||||
break;
|
||||
case VK_FORMAT_R8G8B8_SNORM:
|
||||
result = 3;
|
||||
break;
|
||||
case VK_FORMAT_R8G8B8_USCALED:
|
||||
result = 3;
|
||||
break;
|
||||
case VK_FORMAT_R8G8B8_SSCALED:
|
||||
result = 3;
|
||||
break;
|
||||
case VK_FORMAT_R8G8B8_UINT:
|
||||
result = 3;
|
||||
break;
|
||||
case VK_FORMAT_R8G8B8_SINT:
|
||||
result = 3;
|
||||
break;
|
||||
case VK_FORMAT_R8G8B8_SRGB:
|
||||
result = 3;
|
||||
break;
|
||||
case VK_FORMAT_B8G8R8_UNORM:
|
||||
result = 3;
|
||||
break;
|
||||
case VK_FORMAT_B8G8R8_SNORM:
|
||||
result = 3;
|
||||
break;
|
||||
case VK_FORMAT_B8G8R8_USCALED:
|
||||
result = 3;
|
||||
break;
|
||||
case VK_FORMAT_B8G8R8_SSCALED:
|
||||
result = 3;
|
||||
break;
|
||||
case VK_FORMAT_B8G8R8_UINT:
|
||||
result = 3;
|
||||
break;
|
||||
case VK_FORMAT_B8G8R8_SINT:
|
||||
result = 3;
|
||||
break;
|
||||
case VK_FORMAT_B8G8R8_SRGB:
|
||||
result = 3;
|
||||
break;
|
||||
case VK_FORMAT_R8G8B8A8_UNORM:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_R8G8B8A8_SNORM:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_R8G8B8A8_USCALED:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_R8G8B8A8_SSCALED:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_R8G8B8A8_UINT:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_R8G8B8A8_SINT:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_R8G8B8A8_SRGB:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_B8G8R8A8_UNORM:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_B8G8R8A8_SNORM:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_B8G8R8A8_USCALED:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_B8G8R8A8_SSCALED:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_B8G8R8A8_UINT:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_B8G8R8A8_SINT:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_B8G8R8A8_SRGB:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_A8B8G8R8_SNORM_PACK32:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_A8B8G8R8_USCALED_PACK32:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_A8B8G8R8_SSCALED_PACK32:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_A8B8G8R8_UINT_PACK32:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_A8B8G8R8_SINT_PACK32:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_A8B8G8R8_SRGB_PACK32:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_A2R10G10B10_UNORM_PACK32:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_A2R10G10B10_SNORM_PACK32:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_A2R10G10B10_USCALED_PACK32:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_A2R10G10B10_SSCALED_PACK32:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_A2R10G10B10_UINT_PACK32:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_A2R10G10B10_SINT_PACK32:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_A2B10G10R10_SNORM_PACK32:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_A2B10G10R10_USCALED_PACK32:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_A2B10G10R10_SSCALED_PACK32:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_A2B10G10R10_UINT_PACK32:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_A2B10G10R10_SINT_PACK32:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_R16_UNORM:
|
||||
result = 2;
|
||||
break;
|
||||
case VK_FORMAT_R16_SNORM:
|
||||
result = 2;
|
||||
break;
|
||||
case VK_FORMAT_R16_USCALED:
|
||||
result = 2;
|
||||
break;
|
||||
case VK_FORMAT_R16_SSCALED:
|
||||
result = 2;
|
||||
break;
|
||||
case VK_FORMAT_R16_UINT:
|
||||
result = 2;
|
||||
break;
|
||||
case VK_FORMAT_R16_SINT:
|
||||
result = 2;
|
||||
break;
|
||||
case VK_FORMAT_R16_SFLOAT:
|
||||
result = 2;
|
||||
break;
|
||||
case VK_FORMAT_R16G16_UNORM:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_R16G16_SNORM:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_R16G16_USCALED:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_R16G16_SSCALED:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_R16G16_UINT:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_R16G16_SINT:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_R16G16_SFLOAT:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_R16G16B16_UNORM:
|
||||
result = 6;
|
||||
break;
|
||||
case VK_FORMAT_R16G16B16_SNORM:
|
||||
result = 6;
|
||||
break;
|
||||
case VK_FORMAT_R16G16B16_USCALED:
|
||||
result = 6;
|
||||
break;
|
||||
case VK_FORMAT_R16G16B16_SSCALED:
|
||||
result = 6;
|
||||
break;
|
||||
case VK_FORMAT_R16G16B16_UINT:
|
||||
result = 6;
|
||||
break;
|
||||
case VK_FORMAT_R16G16B16_SINT:
|
||||
result = 6;
|
||||
break;
|
||||
case VK_FORMAT_R16G16B16_SFLOAT:
|
||||
result = 6;
|
||||
break;
|
||||
case VK_FORMAT_R16G16B16A16_UNORM:
|
||||
result = 8;
|
||||
break;
|
||||
case VK_FORMAT_R16G16B16A16_SNORM:
|
||||
result = 8;
|
||||
break;
|
||||
case VK_FORMAT_R16G16B16A16_USCALED:
|
||||
result = 8;
|
||||
break;
|
||||
case VK_FORMAT_R16G16B16A16_SSCALED:
|
||||
result = 8;
|
||||
break;
|
||||
case VK_FORMAT_R16G16B16A16_UINT:
|
||||
result = 8;
|
||||
break;
|
||||
case VK_FORMAT_R16G16B16A16_SINT:
|
||||
result = 8;
|
||||
break;
|
||||
case VK_FORMAT_R16G16B16A16_SFLOAT:
|
||||
result = 8;
|
||||
break;
|
||||
case VK_FORMAT_R32_UINT:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_R32_SINT:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_R32_SFLOAT:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_R32G32_UINT:
|
||||
result = 8;
|
||||
break;
|
||||
case VK_FORMAT_R32G32_SINT:
|
||||
result = 8;
|
||||
break;
|
||||
case VK_FORMAT_R32G32_SFLOAT:
|
||||
result = 8;
|
||||
break;
|
||||
case VK_FORMAT_R32G32B32_UINT:
|
||||
result = 12;
|
||||
break;
|
||||
case VK_FORMAT_R32G32B32_SINT:
|
||||
result = 12;
|
||||
break;
|
||||
case VK_FORMAT_R32G32B32_SFLOAT:
|
||||
result = 12;
|
||||
break;
|
||||
case VK_FORMAT_R32G32B32A32_UINT:
|
||||
result = 16;
|
||||
break;
|
||||
case VK_FORMAT_R32G32B32A32_SINT:
|
||||
result = 16;
|
||||
break;
|
||||
case VK_FORMAT_R32G32B32A32_SFLOAT:
|
||||
result = 16;
|
||||
break;
|
||||
case VK_FORMAT_R64_UINT:
|
||||
result = 8;
|
||||
break;
|
||||
case VK_FORMAT_R64_SINT:
|
||||
result = 8;
|
||||
break;
|
||||
case VK_FORMAT_R64_SFLOAT:
|
||||
result = 8;
|
||||
break;
|
||||
case VK_FORMAT_R64G64_UINT:
|
||||
result = 16;
|
||||
break;
|
||||
case VK_FORMAT_R64G64_SINT:
|
||||
result = 16;
|
||||
break;
|
||||
case VK_FORMAT_R64G64_SFLOAT:
|
||||
result = 16;
|
||||
break;
|
||||
case VK_FORMAT_R64G64B64_UINT:
|
||||
result = 24;
|
||||
break;
|
||||
case VK_FORMAT_R64G64B64_SINT:
|
||||
result = 24;
|
||||
break;
|
||||
case VK_FORMAT_R64G64B64_SFLOAT:
|
||||
result = 24;
|
||||
break;
|
||||
case VK_FORMAT_R64G64B64A64_UINT:
|
||||
result = 32;
|
||||
break;
|
||||
case VK_FORMAT_R64G64B64A64_SINT:
|
||||
result = 32;
|
||||
break;
|
||||
case VK_FORMAT_R64G64B64A64_SFLOAT:
|
||||
result = 32;
|
||||
break;
|
||||
case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
|
||||
result = 4;
|
||||
break;
|
||||
case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32:
|
||||
result = 4;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
int main(int argn, char** argv) {
|
||||
SpvReflectShaderModule module = {};
|
||||
SpvReflectResult result = spvReflectCreateShaderModule(sizeof(k_sample_spv), k_sample_spv, &module);
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
|
||||
uint32_t count = 0;
|
||||
result = spvReflectEnumerateInputVariables(&module, &count, NULL);
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
|
||||
std::vector<SpvReflectInterfaceVariable*> input_vars(count);
|
||||
result = spvReflectEnumerateInputVariables(&module, &count, input_vars.data());
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
|
||||
count = 0;
|
||||
result = spvReflectEnumerateOutputVariables(&module, &count, NULL);
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
|
||||
std::vector<SpvReflectInterfaceVariable*> output_vars(count);
|
||||
result = spvReflectEnumerateOutputVariables(&module, &count, output_vars.data());
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
|
||||
#if defined(SPIRV_REFLECT_HAS_VULKAN_H)
|
||||
if (module.shader_stage == SPV_REFLECT_SHADER_STAGE_VERTEX_BIT) {
|
||||
// Demonstrates how to generate all necessary data structures to populate
|
||||
// a VkPipelineVertexInputStateCreateInfo structure, given the module's
|
||||
// expected input variables.
|
||||
//
|
||||
// Simplifying assumptions:
|
||||
// - All vertex input attributes are sourced from a single vertex buffer,
|
||||
// bound to VB slot 0.
|
||||
// - Each vertex's attribute are laid out in ascending order by location.
|
||||
// - The format of each attribute matches its usage in the shader;
|
||||
// float4 -> VK_FORMAT_R32G32B32A32_FLOAT, etc. No attribute compression
|
||||
// is applied.
|
||||
// - All attributes are provided per-vertex, not per-instance.
|
||||
VkVertexInputBindingDescription binding_description = {};
|
||||
binding_description.binding = 0;
|
||||
binding_description.stride = 0; // computed below
|
||||
binding_description.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
|
||||
VkPipelineVertexInputStateCreateInfo vertex_input_state_create_info = {
|
||||
VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO};
|
||||
std::vector<VkVertexInputAttributeDescription> attribute_descriptions;
|
||||
attribute_descriptions.reserve(input_vars.size());
|
||||
for (size_t i_var = 0; i_var < input_vars.size(); ++i_var) {
|
||||
const SpvReflectInterfaceVariable& refl_var = *(input_vars[i_var]);
|
||||
// ignore built-in variables
|
||||
if (refl_var.decoration_flags & SPV_REFLECT_DECORATION_BUILT_IN) {
|
||||
continue;
|
||||
}
|
||||
VkVertexInputAttributeDescription attr_desc{};
|
||||
attr_desc.location = refl_var.location;
|
||||
attr_desc.binding = binding_description.binding;
|
||||
attr_desc.format = static_cast<VkFormat>(refl_var.format);
|
||||
attr_desc.offset = 0; // final offset computed below after sorting.
|
||||
attribute_descriptions.push_back(attr_desc);
|
||||
}
|
||||
// Sort attributes by location
|
||||
std::sort(std::begin(attribute_descriptions), std::end(attribute_descriptions),
|
||||
[](const VkVertexInputAttributeDescription& a, const VkVertexInputAttributeDescription& b) {
|
||||
return a.location < b.location;
|
||||
});
|
||||
// Compute final offsets of each attribute, and total vertex stride.
|
||||
for (auto& attribute : attribute_descriptions) {
|
||||
uint32_t format_size = FormatSize(attribute.format);
|
||||
attribute.offset = binding_description.stride;
|
||||
binding_description.stride += format_size;
|
||||
}
|
||||
// Nothing further is done with attribute_descriptions or
|
||||
// binding_description in this sample. A real application would probably
|
||||
// derive this information from its mesh format(s); a similar mechanism
|
||||
// could be used to ensure mesh/shader compatibility.
|
||||
}
|
||||
#endif
|
||||
|
||||
// Log the interface variables to stdout
|
||||
const char* t = " ";
|
||||
const char* tt = " ";
|
||||
|
||||
PrintModuleInfo(std::cout, module);
|
||||
std::cout << "\n\n";
|
||||
|
||||
std::cout << "Input variables:"
|
||||
<< "\n";
|
||||
for (size_t index = 0; index < input_vars.size(); ++index) {
|
||||
auto p_var = input_vars[index];
|
||||
|
||||
// input variables can also be retrieved directly from the module, by
|
||||
// location (unless the location is (uint32_t)-1, as is the case with
|
||||
// built-in inputs)
|
||||
auto p_var2 = spvReflectGetInputVariableByLocation(&module, p_var->location, &result);
|
||||
if (p_var->location == UINT32_MAX) {
|
||||
assert(result == SPV_REFLECT_RESULT_ERROR_ELEMENT_NOT_FOUND);
|
||||
assert(p_var2 == nullptr);
|
||||
} else {
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
assert(p_var == p_var2);
|
||||
}
|
||||
(void)p_var2;
|
||||
|
||||
// input variables can also be retrieved directly from the module, by
|
||||
// semantic (if present)
|
||||
p_var2 = spvReflectGetInputVariableBySemantic(&module, p_var->semantic, &result);
|
||||
if (!p_var->semantic) {
|
||||
assert(result == SPV_REFLECT_RESULT_ERROR_NULL_POINTER);
|
||||
assert(p_var2 == nullptr);
|
||||
} else if (p_var->semantic[0] != '\0') {
|
||||
assert(result == SPV_REFLECT_RESULT_ERROR_ELEMENT_NOT_FOUND);
|
||||
assert(p_var2 == nullptr);
|
||||
} else {
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
assert(p_var == p_var2);
|
||||
}
|
||||
(void)p_var2;
|
||||
|
||||
std::cout << t << index << ":"
|
||||
<< "\n";
|
||||
PrintInterfaceVariable(std::cout, module.source_language, *p_var, tt);
|
||||
std::cout << "\n\n";
|
||||
}
|
||||
|
||||
std::cout << "Output variables:"
|
||||
<< "\n";
|
||||
for (size_t index = 0; index < output_vars.size(); ++index) {
|
||||
auto p_var = output_vars[index];
|
||||
|
||||
// output variables can also be retrieved directly from the module, by
|
||||
// location (unless the location is (uint32_t)-1, as is the case with
|
||||
// built-in outputs)
|
||||
auto p_var2 = spvReflectGetOutputVariableByLocation(&module, p_var->location, &result);
|
||||
if (p_var->location == UINT32_MAX) {
|
||||
assert(result == SPV_REFLECT_RESULT_ERROR_ELEMENT_NOT_FOUND);
|
||||
assert(p_var2 == nullptr);
|
||||
} else {
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
assert(p_var == p_var2);
|
||||
}
|
||||
(void)p_var2;
|
||||
|
||||
// output variables can also be retrieved directly from the module, by
|
||||
// semantic (if present)
|
||||
p_var2 = spvReflectGetOutputVariableBySemantic(&module, p_var->semantic, &result);
|
||||
if (!p_var->semantic) {
|
||||
assert(result == SPV_REFLECT_RESULT_ERROR_NULL_POINTER);
|
||||
assert(p_var2 == nullptr);
|
||||
} else if (p_var->semantic[0] != '\0') {
|
||||
assert(result == SPV_REFLECT_RESULT_ERROR_ELEMENT_NOT_FOUND);
|
||||
assert(p_var2 == nullptr);
|
||||
} else {
|
||||
assert(result == SPV_REFLECT_RESULT_SUCCESS);
|
||||
assert(p_var == p_var2);
|
||||
}
|
||||
(void)p_var2;
|
||||
|
||||
std::cout << t << index << ":"
|
||||
<< "\n";
|
||||
PrintInterfaceVariable(std::cout, module.source_language, *p_var, tt);
|
||||
std::cout << "\n\n";
|
||||
}
|
||||
|
||||
spvReflectDestroyShaderModule(&module);
|
||||
|
||||
return 0;
|
||||
}
|
||||
64
lib/All/SPIRV-Reflect/examples/sample.hlsl
Normal file
64
lib/All/SPIRV-Reflect/examples/sample.hlsl
Normal file
@@ -0,0 +1,64 @@
|
||||
Texture2D MyTexture : register(t0, space0);
|
||||
SamplerState MySampler : register(s1, space1);
|
||||
|
||||
struct RGB {
|
||||
float r;
|
||||
float g;
|
||||
float b;
|
||||
};
|
||||
|
||||
struct UBO {
|
||||
float4x4 XformMatrix;
|
||||
float3 Scale;
|
||||
RGB Rgb;
|
||||
float t;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
ConstantBuffer<UBO> MyConstants : register(b2, space2);
|
||||
|
||||
struct Data {
|
||||
float4 Element;
|
||||
};
|
||||
|
||||
ConsumeStructuredBuffer<Data> MyBufferIn : register(u3, space2);
|
||||
AppendStructuredBuffer<Data> MyBufferOut : register(u4, space2);
|
||||
|
||||
struct PSInput {
|
||||
float4 Position : SV_POSITION;
|
||||
float3 Normal : NORMAL;
|
||||
float3 Color : COLOR;
|
||||
float Alpha : OPACITY;
|
||||
float4 Scaling : SCALE;
|
||||
float2 TexCoord0 : TEXCOORD0;
|
||||
float2 TexCoord1 : TEXCOORD1;
|
||||
float2 TexCoord2 : TEXCOORD2;
|
||||
};
|
||||
|
||||
struct PSOutput {
|
||||
float4 oColor0 : SV_TARGET0;
|
||||
float4 oColor1 : SV_TARGET1;
|
||||
float4 oColor2 : SV_TARGET2;
|
||||
float4 oColor3 : SV_TARGET3;
|
||||
float4 oColor4 : SV_TARGET4;
|
||||
float4 oColor5 : SV_TARGET5;
|
||||
float4 oColor6 : SV_TARGET6;
|
||||
float4 oColor7 : SV_TARGET7;
|
||||
};
|
||||
|
||||
PSOutput main(PSInput input)
|
||||
{
|
||||
Data val = MyBufferIn[0];
|
||||
MyBufferOut[0] = val;
|
||||
|
||||
PSOutput ret;
|
||||
ret.oColor0 = mul(MyConstants.XformMatrix, input.Position);
|
||||
ret.oColor1 = float4(input.Normal, 1) + float4(MyConstants.Scale, 0);
|
||||
ret.oColor2 = float4(input.Color, 1);
|
||||
ret.oColor3 = float4(MyTexture.Sample(MySampler, input.TexCoord0).xyz, input.Alpha);
|
||||
ret.oColor4 = input.Scaling;
|
||||
ret.oColor5 = float4(input.TexCoord0, 0, 0);
|
||||
ret.oColor6 = float4(input.TexCoord1, 0, 0);
|
||||
ret.oColor7 = float4(input.TexCoord2, 0, 0);
|
||||
return ret;
|
||||
}
|
||||
BIN
lib/All/SPIRV-Reflect/examples/sample.spv
Normal file
BIN
lib/All/SPIRV-Reflect/examples/sample.spv
Normal file
Binary file not shown.
527
lib/All/SPIRV-Reflect/examples/sample_spv.h
Normal file
527
lib/All/SPIRV-Reflect/examples/sample_spv.h
Normal file
@@ -0,0 +1,527 @@
|
||||
#ifndef SAMPLE_SPV_H
|
||||
#define SAMPLE_SPV_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* Source from sample.hlsl
|
||||
|
||||
Texture2D MyTexture : register(t0, space0);
|
||||
SamplerState MySampler : register(s1, space1);
|
||||
|
||||
struct RGB {
|
||||
float r;
|
||||
float g;
|
||||
float b;
|
||||
};
|
||||
|
||||
struct UBO {
|
||||
float4x4 XformMatrix;
|
||||
float3 Scale;
|
||||
RGB Rgb;
|
||||
float t;
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
ConstantBuffer<UBO> MyConstants : register(b2, space2);
|
||||
|
||||
struct Data {
|
||||
float4 Element;
|
||||
};
|
||||
|
||||
ConsumeStructuredBuffer<Data> MyBufferIn : register(u3, space2);
|
||||
AppendStructuredBuffer<Data> MyBufferOut : register(u4, space2);
|
||||
|
||||
struct PSInput {
|
||||
float4 Position : SV_POSITION;
|
||||
float3 Normal : NORMAL;
|
||||
float3 Color : COLOR;
|
||||
float Alpha : OPACITY;
|
||||
float4 Scaling : SCALE;
|
||||
float2 TexCoord0 : TEXCOORD0;
|
||||
float2 TexCoord1 : TEXCOORD1;
|
||||
float2 TexCoord2 : TEXCOORD2;
|
||||
};
|
||||
|
||||
struct PSOutput {
|
||||
float4 oColor0 : SV_TARGET0;
|
||||
float4 oColor1 : SV_TARGET1;
|
||||
float4 oColor2 : SV_TARGET2;
|
||||
float4 oColor3 : SV_TARGET3;
|
||||
float4 oColor4 : SV_TARGET4;
|
||||
float4 oColor5 : SV_TARGET5;
|
||||
float4 oColor6 : SV_TARGET6;
|
||||
float4 oColor7 : SV_TARGET7;
|
||||
};
|
||||
|
||||
PSOutput main(PSInput input)
|
||||
{
|
||||
Data val = MyBufferIn[0];
|
||||
MyBufferOut[0] = val;
|
||||
|
||||
PSOutput ret;
|
||||
ret.oColor0 = mul(MyConstants.XformMatrix, input.Position);
|
||||
ret.oColor1 = float4(input.Normal, 1) + float4(MyConstants.Scale, 0);
|
||||
ret.oColor2 = float4(input.Color, 1);
|
||||
ret.oColor3 = float4(MyTexture.Sample(MySampler, input.TexCoord0).xyz, input.Alpha);
|
||||
ret.oColor4 = input.Scaling;
|
||||
ret.oColor5 = float4(input.TexCoord0, 0, 0);
|
||||
ret.oColor6 = float4(input.TexCoord1, 0, 0);
|
||||
ret.oColor7 = float4(input.TexCoord2, 0, 0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
// Imported from file 'sample.spv'
|
||||
const uint32_t k_sample_spv[] = {
|
||||
0x07230203,0x00010000,0x000d0004,0x00000106,
|
||||
0x00000000,0x00020011,0x00000001,0x0006000b,
|
||||
0x00000001,0x4c534c47,0x6474732e,0x3035342e,
|
||||
0x00000000,0x0003000e,0x00000000,0x00000001,
|
||||
0x0015000f,0x00000004,0x00000004,0x6e69616d,
|
||||
0x00000000,0x00000086,0x0000008a,0x0000008d,
|
||||
0x00000091,0x00000094,0x00000098,0x0000009b,
|
||||
0x0000009e,0x000000a6,0x000000a9,0x000000ac,
|
||||
0x000000af,0x000000b2,0x000000b5,0x000000b8,
|
||||
0x000000bb,0x00030010,0x00000004,0x00000007,
|
||||
0x00030003,0x00000005,0x000001f4,0x000a0004,
|
||||
0x475f4c47,0x4c474f4f,0x70635f45,0x74735f70,
|
||||
0x5f656c79,0x656e696c,0x7269645f,0x69746365,
|
||||
0x00006576,0x00080004,0x475f4c47,0x4c474f4f,
|
||||
0x6e695f45,0x64756c63,0x69645f65,0x74636572,
|
||||
0x00657669,0x00040005,0x00000004,0x6e69616d,
|
||||
0x00000000,0x00040005,0x00000014,0x61746144,
|
||||
0x00000000,0x00050006,0x00000014,0x00000000,
|
||||
0x6d656c45,0x00746e65,0x00050005,0x00000016,
|
||||
0x7542794d,0x72656666,0x00006e49,0x00050006,
|
||||
0x00000016,0x00000000,0x74616440,0x00000061,
|
||||
0x00050005,0x00000018,0x7542794d,0x72656666,
|
||||
0x00006e49,0x00050005,0x00000021,0x7542794d,
|
||||
0x72656666,0x0074754f,0x00030005,0x0000002c,
|
||||
0x00424752,0x00040006,0x0000002c,0x00000000,
|
||||
0x00000072,0x00040006,0x0000002c,0x00000001,
|
||||
0x00000067,0x00040006,0x0000002c,0x00000002,
|
||||
0x00000062,0x00050005,0x0000002d,0x6f43794d,
|
||||
0x6174736e,0x0073746e,0x00060006,0x0000002d,
|
||||
0x00000000,0x726f6658,0x74614d6d,0x00786972,
|
||||
0x00050006,0x0000002d,0x00000001,0x6c616353,
|
||||
0x00000065,0x00040006,0x0000002d,0x00000002,
|
||||
0x00626752,0x00040006,0x0000002d,0x00000003,
|
||||
0x00000074,0x00040006,0x0000002d,0x00000004,
|
||||
0x00007675,0x00050005,0x0000002f,0x6f43794d,
|
||||
0x6174736e,0x0073746e,0x00050005,0x00000053,
|
||||
0x6554794d,0x72757478,0x00000065,0x00050005,
|
||||
0x00000057,0x6153794d,0x656c706d,0x00000072,
|
||||
0x00060005,0x00000086,0x75706e69,0x6f502e74,
|
||||
0x69746973,0x00006e6f,0x00060005,0x0000008a,
|
||||
0x75706e69,0x6f4e2e74,0x6c616d72,0x00000000,
|
||||
0x00050005,0x0000008d,0x75706e69,0x6f432e74,
|
||||
0x00726f6c,0x00050005,0x00000091,0x75706e69,
|
||||
0x6c412e74,0x00616870,0x00060005,0x00000094,
|
||||
0x75706e69,0x63532e74,0x6e696c61,0x00000067,
|
||||
0x00060005,0x00000098,0x75706e69,0x65542e74,
|
||||
0x6f6f4378,0x00306472,0x00060005,0x0000009b,
|
||||
0x75706e69,0x65542e74,0x6f6f4378,0x00316472,
|
||||
0x00060005,0x0000009e,0x75706e69,0x65542e74,
|
||||
0x6f6f4378,0x00326472,0x00090005,0x000000a6,
|
||||
0x746e6540,0x6f507972,0x4f746e69,0x75707475,
|
||||
0x436f2e74,0x726f6c6f,0x00000030,0x00090005,
|
||||
0x000000a9,0x746e6540,0x6f507972,0x4f746e69,
|
||||
0x75707475,0x436f2e74,0x726f6c6f,0x00000031,
|
||||
0x00090005,0x000000ac,0x746e6540,0x6f507972,
|
||||
0x4f746e69,0x75707475,0x436f2e74,0x726f6c6f,
|
||||
0x00000032,0x00090005,0x000000af,0x746e6540,
|
||||
0x6f507972,0x4f746e69,0x75707475,0x436f2e74,
|
||||
0x726f6c6f,0x00000033,0x00090005,0x000000b2,
|
||||
0x746e6540,0x6f507972,0x4f746e69,0x75707475,
|
||||
0x436f2e74,0x726f6c6f,0x00000034,0x00090005,
|
||||
0x000000b5,0x746e6540,0x6f507972,0x4f746e69,
|
||||
0x75707475,0x436f2e74,0x726f6c6f,0x00000035,
|
||||
0x00090005,0x000000b8,0x746e6540,0x6f507972,
|
||||
0x4f746e69,0x75707475,0x436f2e74,0x726f6c6f,
|
||||
0x00000036,0x00090005,0x000000bb,0x746e6540,
|
||||
0x6f507972,0x4f746e69,0x75707475,0x436f2e74,
|
||||
0x726f6c6f,0x00000037,0x00050048,0x00000014,
|
||||
0x00000000,0x00000023,0x00000000,0x00040047,
|
||||
0x00000015,0x00000006,0x00000010,0x00050048,
|
||||
0x00000016,0x00000000,0x00000023,0x00000000,
|
||||
0x00030047,0x00000016,0x00000003,0x00040047,
|
||||
0x00000018,0x00000022,0x00000002,0x00040047,
|
||||
0x00000018,0x00000021,0x00000003,0x00040047,
|
||||
0x00000021,0x00000022,0x00000002,0x00040047,
|
||||
0x00000021,0x00000021,0x00000004,0x00050048,
|
||||
0x0000002c,0x00000000,0x00000023,0x00000000,
|
||||
0x00050048,0x0000002c,0x00000001,0x00000023,
|
||||
0x00000004,0x00050048,0x0000002c,0x00000002,
|
||||
0x00000023,0x00000008,0x00040048,0x0000002d,
|
||||
0x00000000,0x00000004,0x00050048,0x0000002d,
|
||||
0x00000000,0x00000023,0x00000000,0x00050048,
|
||||
0x0000002d,0x00000000,0x00000007,0x00000010,
|
||||
0x00050048,0x0000002d,0x00000001,0x00000023,
|
||||
0x00000040,0x00050048,0x0000002d,0x00000002,
|
||||
0x00000023,0x00000050,0x00050048,0x0000002d,
|
||||
0x00000003,0x00000023,0x00000060,0x00050048,
|
||||
0x0000002d,0x00000004,0x00000023,0x00000064,
|
||||
0x00030047,0x0000002d,0x00000002,0x00040047,
|
||||
0x0000002f,0x00000022,0x00000002,0x00040047,
|
||||
0x0000002f,0x00000021,0x00000002,0x00040047,
|
||||
0x00000053,0x00000022,0x00000000,0x00040047,
|
||||
0x00000053,0x00000021,0x00000000,0x00040047,
|
||||
0x00000057,0x00000022,0x00000001,0x00040047,
|
||||
0x00000057,0x00000021,0x00000001,0x00040047,
|
||||
0x00000086,0x0000000b,0x0000000f,0x00040047,
|
||||
0x0000008a,0x0000001e,0x00000000,0x00040047,
|
||||
0x0000008d,0x0000001e,0x00000001,0x00040047,
|
||||
0x00000091,0x0000001e,0x00000002,0x00040047,
|
||||
0x00000094,0x0000001e,0x00000003,0x00040047,
|
||||
0x00000098,0x0000001e,0x00000004,0x00040047,
|
||||
0x0000009b,0x0000001e,0x00000005,0x00040047,
|
||||
0x0000009e,0x0000001e,0x00000006,0x00040047,
|
||||
0x000000a6,0x0000001e,0x00000000,0x00040047,
|
||||
0x000000a9,0x0000001e,0x00000001,0x00040047,
|
||||
0x000000ac,0x0000001e,0x00000002,0x00040047,
|
||||
0x000000af,0x0000001e,0x00000003,0x00040047,
|
||||
0x000000b2,0x0000001e,0x00000004,0x00040047,
|
||||
0x000000b5,0x0000001e,0x00000005,0x00040047,
|
||||
0x000000b8,0x0000001e,0x00000006,0x00040047,
|
||||
0x000000bb,0x0000001e,0x00000007,0x00020013,
|
||||
0x00000002,0x00030021,0x00000003,0x00000002,
|
||||
0x00030016,0x00000006,0x00000020,0x00040017,
|
||||
0x00000007,0x00000006,0x00000004,0x00040017,
|
||||
0x00000008,0x00000006,0x00000003,0x00040017,
|
||||
0x00000009,0x00000006,0x00000002,0x0003001e,
|
||||
0x00000014,0x00000007,0x0003001d,0x00000015,
|
||||
0x00000014,0x0003001e,0x00000016,0x00000015,
|
||||
0x00040020,0x00000017,0x00000002,0x00000016,
|
||||
0x0004003b,0x00000017,0x00000018,0x00000002,
|
||||
0x00040015,0x00000019,0x00000020,0x00000001,
|
||||
0x0004002b,0x00000019,0x0000001a,0x00000000,
|
||||
0x00040020,0x0000001b,0x00000002,0x00000014,
|
||||
0x0004003b,0x00000017,0x00000021,0x00000002,
|
||||
0x00040020,0x00000025,0x00000002,0x00000007,
|
||||
0x00040018,0x0000002b,0x00000007,0x00000004,
|
||||
0x0005001e,0x0000002c,0x00000006,0x00000006,
|
||||
0x00000006,0x0007001e,0x0000002d,0x0000002b,
|
||||
0x00000008,0x0000002c,0x00000006,0x00000009,
|
||||
0x00040020,0x0000002e,0x00000002,0x0000002d,
|
||||
0x0004003b,0x0000002e,0x0000002f,0x00000002,
|
||||
0x00040020,0x00000030,0x00000002,0x0000002b,
|
||||
0x0004002b,0x00000019,0x00000035,0x00000001,
|
||||
0x0004002b,0x00000006,0x00000039,0x3f800000,
|
||||
0x00040020,0x0000003e,0x00000002,0x00000008,
|
||||
0x0004002b,0x00000006,0x00000041,0x00000000,
|
||||
0x00090019,0x00000051,0x00000006,0x00000001,
|
||||
0x00000000,0x00000000,0x00000000,0x00000001,
|
||||
0x00000000,0x00040020,0x00000052,0x00000000,
|
||||
0x00000051,0x0004003b,0x00000052,0x00000053,
|
||||
0x00000000,0x0002001a,0x00000055,0x00040020,
|
||||
0x00000056,0x00000000,0x00000055,0x0004003b,
|
||||
0x00000056,0x00000057,0x00000000,0x0003001b,
|
||||
0x00000059,0x00000051,0x00040020,0x00000085,
|
||||
0x00000001,0x00000007,0x0004003b,0x00000085,
|
||||
0x00000086,0x00000001,0x00040020,0x00000089,
|
||||
0x00000001,0x00000008,0x0004003b,0x00000089,
|
||||
0x0000008a,0x00000001,0x0004003b,0x00000089,
|
||||
0x0000008d,0x00000001,0x00040020,0x00000090,
|
||||
0x00000001,0x00000006,0x0004003b,0x00000090,
|
||||
0x00000091,0x00000001,0x0004003b,0x00000085,
|
||||
0x00000094,0x00000001,0x00040020,0x00000097,
|
||||
0x00000001,0x00000009,0x0004003b,0x00000097,
|
||||
0x00000098,0x00000001,0x0004003b,0x00000097,
|
||||
0x0000009b,0x00000001,0x0004003b,0x00000097,
|
||||
0x0000009e,0x00000001,0x00040020,0x000000a5,
|
||||
0x00000003,0x00000007,0x0004003b,0x000000a5,
|
||||
0x000000a6,0x00000003,0x0004003b,0x000000a5,
|
||||
0x000000a9,0x00000003,0x0004003b,0x000000a5,
|
||||
0x000000ac,0x00000003,0x0004003b,0x000000a5,
|
||||
0x000000af,0x00000003,0x0004003b,0x000000a5,
|
||||
0x000000b2,0x00000003,0x0004003b,0x000000a5,
|
||||
0x000000b5,0x00000003,0x0004003b,0x000000a5,
|
||||
0x000000b8,0x00000003,0x0004003b,0x000000a5,
|
||||
0x000000bb,0x00000003,0x00050036,0x00000002,
|
||||
0x00000004,0x00000000,0x00000003,0x000200f8,
|
||||
0x00000005,0x0004003d,0x00000007,0x00000087,
|
||||
0x00000086,0x0004003d,0x00000008,0x0000008b,
|
||||
0x0000008a,0x0004003d,0x00000008,0x0000008e,
|
||||
0x0000008d,0x0004003d,0x00000006,0x00000092,
|
||||
0x00000091,0x0004003d,0x00000007,0x00000095,
|
||||
0x00000094,0x0004003d,0x00000009,0x00000099,
|
||||
0x00000098,0x0004003d,0x00000009,0x0000009c,
|
||||
0x0000009b,0x0004003d,0x00000009,0x0000009f,
|
||||
0x0000009e,0x00060041,0x0000001b,0x000000c1,
|
||||
0x00000018,0x0000001a,0x0000001a,0x0004003d,
|
||||
0x00000014,0x000000c2,0x000000c1,0x00050051,
|
||||
0x00000007,0x000000c3,0x000000c2,0x00000000,
|
||||
0x00060041,0x0000001b,0x000000c6,0x00000021,
|
||||
0x0000001a,0x0000001a,0x00050041,0x00000025,
|
||||
0x000000c8,0x000000c6,0x0000001a,0x0003003e,
|
||||
0x000000c8,0x000000c3,0x00050041,0x00000030,
|
||||
0x000000cb,0x0000002f,0x0000001a,0x0004003d,
|
||||
0x0000002b,0x000000cc,0x000000cb,0x00050090,
|
||||
0x00000007,0x000000cd,0x00000087,0x000000cc,
|
||||
0x00050051,0x00000006,0x000000d1,0x0000008b,
|
||||
0x00000000,0x00050051,0x00000006,0x000000d2,
|
||||
0x0000008b,0x00000001,0x00050051,0x00000006,
|
||||
0x000000d3,0x0000008b,0x00000002,0x00070050,
|
||||
0x00000007,0x000000d4,0x000000d1,0x000000d2,
|
||||
0x000000d3,0x00000039,0x00050041,0x0000003e,
|
||||
0x000000d5,0x0000002f,0x00000035,0x0004003d,
|
||||
0x00000008,0x000000d6,0x000000d5,0x00050051,
|
||||
0x00000006,0x000000d7,0x000000d6,0x00000000,
|
||||
0x00050051,0x00000006,0x000000d8,0x000000d6,
|
||||
0x00000001,0x00050051,0x00000006,0x000000d9,
|
||||
0x000000d6,0x00000002,0x00070050,0x00000007,
|
||||
0x000000da,0x000000d7,0x000000d8,0x000000d9,
|
||||
0x00000041,0x00050081,0x00000007,0x000000db,
|
||||
0x000000d4,0x000000da,0x00050051,0x00000006,
|
||||
0x000000df,0x0000008e,0x00000000,0x00050051,
|
||||
0x00000006,0x000000e0,0x0000008e,0x00000001,
|
||||
0x00050051,0x00000006,0x000000e1,0x0000008e,
|
||||
0x00000002,0x00070050,0x00000007,0x000000e2,
|
||||
0x000000df,0x000000e0,0x000000e1,0x00000039,
|
||||
0x0004003d,0x00000051,0x000000e4,0x00000053,
|
||||
0x0004003d,0x00000055,0x000000e5,0x00000057,
|
||||
0x00050056,0x00000059,0x000000e6,0x000000e4,
|
||||
0x000000e5,0x00050057,0x00000007,0x000000e9,
|
||||
0x000000e6,0x00000099,0x0008004f,0x00000008,
|
||||
0x000000ea,0x000000e9,0x000000e9,0x00000000,
|
||||
0x00000001,0x00000002,0x00050051,0x00000006,
|
||||
0x000000ed,0x000000ea,0x00000000,0x00050051,
|
||||
0x00000006,0x000000ee,0x000000ea,0x00000001,
|
||||
0x00050051,0x00000006,0x000000ef,0x000000ea,
|
||||
0x00000002,0x00070050,0x00000007,0x000000f0,
|
||||
0x000000ed,0x000000ee,0x000000ef,0x00000092,
|
||||
0x00050051,0x00000006,0x000000f7,0x00000099,
|
||||
0x00000000,0x00050051,0x00000006,0x000000f8,
|
||||
0x00000099,0x00000001,0x00070050,0x00000007,
|
||||
0x000000f9,0x000000f7,0x000000f8,0x00000041,
|
||||
0x00000041,0x00050051,0x00000006,0x000000fd,
|
||||
0x0000009c,0x00000000,0x00050051,0x00000006,
|
||||
0x000000fe,0x0000009c,0x00000001,0x00070050,
|
||||
0x00000007,0x000000ff,0x000000fd,0x000000fe,
|
||||
0x00000041,0x00000041,0x00050051,0x00000006,
|
||||
0x00000103,0x0000009f,0x00000000,0x00050051,
|
||||
0x00000006,0x00000104,0x0000009f,0x00000001,
|
||||
0x00070050,0x00000007,0x00000105,0x00000103,
|
||||
0x00000104,0x00000041,0x00000041,0x0003003e,
|
||||
0x000000a6,0x000000cd,0x0003003e,0x000000a9,
|
||||
0x000000db,0x0003003e,0x000000ac,0x000000e2,
|
||||
0x0003003e,0x000000af,0x000000f0,0x0003003e,
|
||||
0x000000b2,0x00000095,0x0003003e,0x000000b5,
|
||||
0x000000f9,0x0003003e,0x000000b8,0x000000ff,
|
||||
0x0003003e,0x000000bb,0x00000105,0x000100fd,
|
||||
0x00010038
|
||||
};
|
||||
|
||||
/* SPIRV Disassembly
|
||||
|
||||
; SPIR-V
|
||||
; Version: 1.0
|
||||
; Generator: Khronos Glslang Reference Front End; 2
|
||||
; Bound: 241
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %4 "main" %117 %121 %124 %128 %131 %135 %138 %141 %149 %152 %155 %158 %161 %164 %167 %170
|
||||
OpExecutionMode %4 OriginUpperLeft
|
||||
OpSource HLSL 500
|
||||
OpName %4 "main"
|
||||
OpName %10 "PSInput"
|
||||
OpMemberName %10 0 "Position"
|
||||
OpMemberName %10 1 "Normal"
|
||||
OpMemberName %10 2 "Color"
|
||||
OpMemberName %10 3 "Alpha"
|
||||
OpMemberName %10 4 "Scaling"
|
||||
OpMemberName %10 5 "TexCoord0"
|
||||
OpMemberName %10 6 "TexCoord1"
|
||||
OpMemberName %10 7 "TexCoord2"
|
||||
OpName %12 "PSOutput"
|
||||
OpMemberName %12 0 "oColor0"
|
||||
OpMemberName %12 1 "oColor1"
|
||||
OpMemberName %12 2 "oColor2"
|
||||
OpMemberName %12 3 "oColor3"
|
||||
OpMemberName %12 4 "oColor4"
|
||||
OpMemberName %12 5 "oColor5"
|
||||
OpMemberName %12 6 "oColor6"
|
||||
OpMemberName %12 7 "oColor7"
|
||||
OpName %17 "Data"
|
||||
OpMemberName %17 0 "Element"
|
||||
OpName %20 "Data"
|
||||
OpMemberName %20 0 "Element"
|
||||
OpName %22 "MyBufferIn"
|
||||
OpMemberName %22 0 "@data"
|
||||
OpName %24 "MyBufferIn"
|
||||
OpName %33 "MyBufferOut"
|
||||
OpName %44 "RGB"
|
||||
OpMemberName %44 0 "r"
|
||||
OpMemberName %44 1 "g"
|
||||
OpMemberName %44 2 "b"
|
||||
OpName %45 "MyConstants"
|
||||
OpMemberName %45 0 "XformMatrix"
|
||||
OpMemberName %45 1 "Scale"
|
||||
OpMemberName %45 2 "Rgb"
|
||||
OpMemberName %45 3 "t"
|
||||
OpMemberName %45 4 "uv"
|
||||
OpName %47 "MyConstants"
|
||||
OpName %117 "input.Position"
|
||||
OpName %121 "input.Normal"
|
||||
OpName %124 "input.Color"
|
||||
OpName %128 "input.Alpha"
|
||||
OpName %131 "input.Scaling"
|
||||
OpName %135 "input.TexCoord0"
|
||||
OpName %138 "input.TexCoord1"
|
||||
OpName %141 "input.TexCoord2"
|
||||
OpName %149 "@entryPointOutput.oColor0"
|
||||
OpName %152 "@entryPointOutput.oColor1"
|
||||
OpName %155 "@entryPointOutput.oColor2"
|
||||
OpName %158 "@entryPointOutput.oColor3"
|
||||
OpName %161 "@entryPointOutput.oColor4"
|
||||
OpName %164 "@entryPointOutput.oColor5"
|
||||
OpName %167 "@entryPointOutput.oColor6"
|
||||
OpName %170 "@entryPointOutput.oColor7"
|
||||
OpMemberDecorate %20 0 Offset 0
|
||||
OpDecorate %21 ArrayStride 16
|
||||
OpMemberDecorate %22 0 Offset 0
|
||||
OpDecorate %22 BufferBlock
|
||||
OpDecorate %24 DescriptorSet 2
|
||||
OpDecorate %24 Binding 3
|
||||
OpDecorate %33 DescriptorSet 2
|
||||
OpDecorate %33 Binding 4
|
||||
OpMemberDecorate %44 0 Offset 0
|
||||
OpMemberDecorate %44 1 Offset 4
|
||||
OpMemberDecorate %44 2 Offset 8
|
||||
OpMemberDecorate %45 0 RowMajor
|
||||
OpMemberDecorate %45 0 Offset 0
|
||||
OpMemberDecorate %45 0 MatrixStride 16
|
||||
OpMemberDecorate %45 1 Offset 64
|
||||
OpMemberDecorate %45 2 Offset 80
|
||||
OpMemberDecorate %45 3 Offset 96
|
||||
OpMemberDecorate %45 4 Offset 100
|
||||
OpDecorate %45 Block
|
||||
OpDecorate %47 DescriptorSet 2
|
||||
OpDecorate %47 Binding 2
|
||||
OpDecorate %117 BuiltIn FragCoord
|
||||
OpDecorate %121 Location 0
|
||||
OpDecorate %124 Location 1
|
||||
OpDecorate %128 Location 2
|
||||
OpDecorate %131 Location 3
|
||||
OpDecorate %135 Location 4
|
||||
OpDecorate %138 Location 5
|
||||
OpDecorate %141 Location 6
|
||||
OpDecorate %149 Location 0
|
||||
OpDecorate %152 Location 1
|
||||
OpDecorate %155 Location 2
|
||||
OpDecorate %158 Location 3
|
||||
OpDecorate %161 Location 4
|
||||
OpDecorate %164 Location 5
|
||||
OpDecorate %167 Location 6
|
||||
OpDecorate %170 Location 7
|
||||
%2 = OpTypeVoid
|
||||
%3 = OpTypeFunction %2
|
||||
%6 = OpTypeFloat 32
|
||||
%7 = OpTypeVector %6 4
|
||||
%8 = OpTypeVector %6 3
|
||||
%9 = OpTypeVector %6 2
|
||||
%10 = OpTypeStruct %7 %8 %8 %6 %7 %9 %9 %9
|
||||
%12 = OpTypeStruct %7 %7 %7 %7 %7 %7 %7 %7
|
||||
%17 = OpTypeStruct %7
|
||||
%20 = OpTypeStruct %7
|
||||
%21 = OpTypeRuntimeArray %20
|
||||
%22 = OpTypeStruct %21
|
||||
%23 = OpTypePointer Uniform %22
|
||||
%24 = OpVariable %23 Uniform
|
||||
%25 = OpTypeInt 32 1
|
||||
%26 = OpConstant %25 0
|
||||
%27 = OpTypePointer Uniform %20
|
||||
%33 = OpVariable %23 Uniform
|
||||
%37 = OpTypePointer Uniform %7
|
||||
%43 = OpTypeMatrix %7 4
|
||||
%44 = OpTypeStruct %6 %6 %6
|
||||
%45 = OpTypeStruct %43 %8 %44 %6 %9
|
||||
%46 = OpTypePointer Uniform %45
|
||||
%47 = OpVariable %46 Uniform
|
||||
%48 = OpTypePointer Uniform %43
|
||||
%53 = OpConstant %25 1
|
||||
%57 = OpConstant %6 1
|
||||
%62 = OpTypePointer Uniform %8
|
||||
%65 = OpConstant %6 0
|
||||
%116 = OpTypePointer Input %7
|
||||
%117 = OpVariable %116 Input
|
||||
%120 = OpTypePointer Input %8
|
||||
%121 = OpVariable %120 Input
|
||||
%124 = OpVariable %120 Input
|
||||
%127 = OpTypePointer Input %6
|
||||
%128 = OpVariable %127 Input
|
||||
%131 = OpVariable %116 Input
|
||||
%134 = OpTypePointer Input %9
|
||||
%135 = OpVariable %134 Input
|
||||
%138 = OpVariable %134 Input
|
||||
%141 = OpVariable %134 Input
|
||||
%148 = OpTypePointer Output %7
|
||||
%149 = OpVariable %148 Output
|
||||
%152 = OpVariable %148 Output
|
||||
%155 = OpVariable %148 Output
|
||||
%158 = OpVariable %148 Output
|
||||
%161 = OpVariable %148 Output
|
||||
%164 = OpVariable %148 Output
|
||||
%167 = OpVariable %148 Output
|
||||
%170 = OpVariable %148 Output
|
||||
%4 = OpFunction %2 None %3
|
||||
%5 = OpLabel
|
||||
%118 = OpLoad %7 %117
|
||||
%122 = OpLoad %8 %121
|
||||
%125 = OpLoad %8 %124
|
||||
%129 = OpLoad %6 %128
|
||||
%132 = OpLoad %7 %131
|
||||
%136 = OpLoad %9 %135
|
||||
%139 = OpLoad %9 %138
|
||||
%142 = OpLoad %9 %141
|
||||
%182 = OpAccessChain %27 %24 %26 %26
|
||||
%183 = OpLoad %20 %182
|
||||
%184 = OpCompositeExtract %7 %183 0
|
||||
%187 = OpAccessChain %27 %33 %26 %26
|
||||
%189 = OpAccessChain %37 %187 %26
|
||||
OpStore %189 %184
|
||||
%192 = OpAccessChain %48 %47 %26
|
||||
%193 = OpLoad %43 %192
|
||||
%194 = OpVectorTimesMatrix %7 %118 %193
|
||||
%198 = OpCompositeExtract %6 %122 0
|
||||
%199 = OpCompositeExtract %6 %122 1
|
||||
%200 = OpCompositeExtract %6 %122 2
|
||||
%201 = OpCompositeConstruct %7 %198 %199 %200 %57
|
||||
%202 = OpAccessChain %62 %47 %53
|
||||
%203 = OpLoad %8 %202
|
||||
%204 = OpCompositeExtract %6 %203 0
|
||||
%205 = OpCompositeExtract %6 %203 1
|
||||
%206 = OpCompositeExtract %6 %203 2
|
||||
%207 = OpCompositeConstruct %7 %204 %205 %206 %65
|
||||
%208 = OpFAdd %7 %201 %207
|
||||
%212 = OpCompositeExtract %6 %125 0
|
||||
%213 = OpCompositeExtract %6 %125 1
|
||||
%214 = OpCompositeExtract %6 %125 2
|
||||
%215 = OpCompositeConstruct %7 %212 %213 %214 %57
|
||||
%219 = OpCompositeConstruct %7 %65 %65 %65 %129
|
||||
%226 = OpCompositeExtract %6 %136 0
|
||||
%227 = OpCompositeExtract %6 %136 1
|
||||
%228 = OpCompositeConstruct %7 %226 %227 %65 %65
|
||||
%232 = OpCompositeExtract %6 %139 0
|
||||
%233 = OpCompositeExtract %6 %139 1
|
||||
%234 = OpCompositeConstruct %7 %232 %233 %65 %65
|
||||
%238 = OpCompositeExtract %6 %142 0
|
||||
%239 = OpCompositeExtract %6 %142 1
|
||||
%240 = OpCompositeConstruct %7 %238 %239 %65 %65
|
||||
OpStore %149 %194
|
||||
OpStore %152 %208
|
||||
OpStore %155 %215
|
||||
OpStore %158 %219
|
||||
OpStore %161 %132
|
||||
OpStore %164 %228
|
||||
OpStore %167 %234
|
||||
OpStore %170 %240
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
*/
|
||||
|
||||
#endif // SAMPLE_SPV_H
|
||||
Reference in New Issue
Block a user