set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
-project(vulkan-cpu CXX C)
+project(kazan CXX C)
if(NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
message(FATAL_ERROR "compiler is not clang")
endif()
-# Vulkan-cpu
+# Kazan
-[![Build Status](https://travis-ci.org/programmerjake/vulkan-cpu.svg?branch=master)](https://travis-ci.org/programmerjake/vulkan-cpu)
+[![Build Status](https://travis-ci.org/kazan-3d/kazan.svg?branch=master)](https://travis-ci.org/kazan-3d/kazan)
Work-in-progress for Vulkan implementation on cpu
## Build in Docker
- docker build -t vulkan-cpu .
+ docker build -t kazan .
## Build under Ubuntu 16.04 (xenial)
sudo apt install build-essential git clang-4.0 llvm-4.0-dev cmake zlib1g-dev libsdl2-dev
- git clone https://github.com/programmerjake/vulkan-cpu.git
- cd vulkan-cpu
+ git clone https://github.com/kazan-3d/kazan.git
+ cd kazan
mkdir build
cd build
cmake .. -DCMAKE_CXX_COMPILER="`which clang++-4.0`" -DCMAKE_C_COMPILER="`which clang-4.0`" -DCMAKE_BUILD_TYPE=Debug
make
+
+## Naming
+
+Kazan used to be named vulkan-cpu. Kazan is a Japanese word that means "volcano".
# GSOC 2017 Landing Page
The code produced as part of GSOC is available here: [gsoc-2017 tag](https://github.com/programmerjake/vulkan-cpu/tree/gsoc-2017)
-I've probably done more work on the code since GSOC, available here: [master branch](https://github.com/programmerjake/vulkan-cpu/tree/master)
+I've probably done more work on the code since GSOC, available here: [master branch](https://github.com/kazan-3d/kazan/tree/master)
## State of code at end of GSOC
Utility functions and types for `enum`s.
-To use, you need to call the `vulkan_cpu_util_generate_enum_traits` macro at namespace scope after the definition of the `enum`:
+To use, you need to call the `kazan_util_generate_enum_traits` macro at namespace scope after the definition of the `enum`:
enum class My_enum // class keyword is optional
{
Value_3 = Value_1, // allows duplicate values
};
- vulkan_cpu_util_generate_enum_traits(My_enum,
+ kazan_util_generate_enum_traits(My_enum,
My_enum::Value_1,
My_enum::Value_2,
My_enum::Value_3);
set(sources demo.cpp)
add_executable(demo ${sources})
target_include_directories(demo PRIVATE ${SDL2_INCLUDE_DIRS})
-target_link_libraries(demo ${libraries} vulkan_cpu_spirv vulkan_cpu_util vulkan_cpu_pipeline vulkan_cpu_vulkan)
+target_link_libraries(demo ${libraries} kazan_spirv kazan_util kazan_pipeline kazan_vulkan)
set_target_properties(demo PROPERTIES
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden)
#error wrong SDL varsion
#endif
-namespace vulkan_cpu
+namespace kazan
{
namespace test
{
int main(int argc, char **argv)
{
- return vulkan_cpu::test::test_main(argc, argv);
+ return kazan::test::test_main(argc, argv);
}
parser.cpp
patch.cpp)
add_executable(generate_spirv_parser ${sources})
-target_link_libraries(generate_spirv_parser vulkan_cpu_util vulkan_cpu_json)
+target_link_libraries(generate_spirv_parser kazan_util kazan_json)
*/
#include "ast.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace generate_spirv_parser
{
#include <vector>
#include <string>
-namespace vulkan_cpu
+namespace kazan
{
namespace generate_spirv_parser
{
variable,
};
-vulkan_cpu_util_generate_enum_traits(
- Instructions_Instruction_Operands_Operand_Quantifier,
- Instructions_Instruction_Operands_Operand_Quantifier::none,
- Instructions_Instruction_Operands_Operand_Quantifier::optional,
- Instructions_Instruction_Operands_Operand_Quantifier::variable);
+kazan_util_generate_enum_traits(Instructions_Instruction_Operands_Operand_Quantifier,
+ Instructions_Instruction_Operands_Operand_Quantifier::none,
+ Instructions_Instruction_Operands_Operand_Quantifier::optional,
+ Instructions_Instruction_Operands_Operand_Quantifier::variable);
struct Instructions
{
std::uint32_t opcode,
Operands operands,
Capabilities capabilities,
- Extensions extensions) noexcept
- : opname(std::move(opname)),
- opcode(opcode),
- operands(std::move(operands)),
- capabilities(std::move(capabilities)),
- extensions(std::move(extensions))
+ Extensions extensions) noexcept : opname(std::move(opname)),
+ opcode(opcode),
+ operands(std::move(operands)),
+ capabilities(std::move(capabilities)),
+ extensions(std::move(extensions))
{
}
json::ast::Value to_json() const;
composite,
};
-vulkan_cpu_util_generate_enum_traits(Operand_kinds_Operand_kind_Category,
- Operand_kinds_Operand_kind_Category::bit_enum,
- Operand_kinds_Operand_kind_Category::value_enum,
- Operand_kinds_Operand_kind_Category::id,
- Operand_kinds_Operand_kind_Category::literal,
- Operand_kinds_Operand_kind_Category::composite);
+kazan_util_generate_enum_traits(Operand_kinds_Operand_kind_Category,
+ Operand_kinds_Operand_kind_Category::bit_enum,
+ Operand_kinds_Operand_kind_Category::value_enum,
+ Operand_kinds_Operand_kind_Category::id,
+ Operand_kinds_Operand_kind_Category::literal,
+ Operand_kinds_Operand_kind_Category::composite);
enum class Operand_kinds_Operand_kind_Literal_kind
{
literal_spec_constant_op_integer,
};
-vulkan_cpu_util_generate_enum_traits(
+kazan_util_generate_enum_traits(
Operand_kinds_Operand_kind_Literal_kind,
Operand_kinds_Operand_kind_Literal_kind::literal_integer,
Operand_kinds_Operand_kind_Literal_kind::literal_string,
#include <list>
#include <deque>
-namespace vulkan_cpu
+namespace kazan
{
namespace generate_spirv_parser
{
struct_closing,
};
-vulkan_cpu_util_generate_enum_traits(Output_part,
- Output_part::file_comments,
- Output_part::include_guard_start,
- Output_part::includes,
- Output_part::namespaces_start,
- Output_part::basic_types,
- Output_part::basic_constants,
- Output_part::id_types,
- Output_part::enum_definitions,
- Output_part::enum_properties_definitions,
- Output_part::literal_types,
- Output_part::enum_structs,
- Output_part::composite_types,
- Output_part::instruction_structs,
- Output_part::instruction_variant,
- Output_part::parse_error_class,
- Output_part::parser_callbacks_class,
- Output_part::dump_callbacks_class,
- Output_part::parser_class,
- Output_part::namespaces_end,
- Output_part::include_guard_end,
- Output_part::struct_opening,
- Output_part::struct_members,
- Output_part::struct_default_constructor,
- Output_part::struct_default_constructor_initializers,
- Output_part::struct_default_constructor_body,
- Output_part::struct_fill_constructor_start,
- Output_part::struct_fill_constructor_args,
- Output_part::struct_fill_constructor_args_end,
- Output_part::struct_fill_constructor_initializers,
- Output_part::struct_fill_constructor_body,
- Output_part::struct_closing);
+kazan_util_generate_enum_traits(Output_part,
+ Output_part::file_comments,
+ Output_part::include_guard_start,
+ Output_part::includes,
+ Output_part::namespaces_start,
+ Output_part::basic_types,
+ Output_part::basic_constants,
+ Output_part::id_types,
+ Output_part::enum_definitions,
+ Output_part::enum_properties_definitions,
+ Output_part::literal_types,
+ Output_part::enum_structs,
+ Output_part::composite_types,
+ Output_part::instruction_structs,
+ Output_part::instruction_variant,
+ Output_part::parse_error_class,
+ Output_part::parser_callbacks_class,
+ Output_part::dump_callbacks_class,
+ Output_part::parser_class,
+ Output_part::namespaces_end,
+ Output_part::include_guard_end,
+ Output_part::struct_opening,
+ Output_part::struct_members,
+ Output_part::struct_default_constructor,
+ Output_part::struct_default_constructor_initializers,
+ Output_part::struct_default_constructor_body,
+ Output_part::struct_fill_constructor_start,
+ Output_part::struct_fill_constructor_args,
+ Output_part::struct_fill_constructor_args_end,
+ Output_part::struct_fill_constructor_initializers,
+ Output_part::struct_fill_constructor_body,
+ Output_part::struct_closing);
static_assert(util::Enum_traits<Output_part>::is_compact,
"mismatch between declaration and generate enum traits");
file_comments << automatically_generated_file_warning_comment
<< state.top_level.copyright;
namespaces_start << R"(
-namespace vulkan_cpu
+namespace kazan
{
namespace spirv
{
}
enum_definitions << R"(@-};
-vulkan_cpu_util_generate_enum_traits()"
+kazan_util_generate_enum_traits()"
<< enumeration.cpp_name;
std::unordered_set<std::uint32_t> values;
for(auto &enumerant : enumeration.enumerants)
#include <utility>
#include <cassert>
-namespace vulkan_cpu
+namespace kazan
{
namespace generate_spirv_parser
{
void write_signed_integer(std::int64_t value, unsigned base = 10);
void write_literal(util::string_view value)
{
- *this << escape_char << literal_command << static_cast<std::uint64_t>(value.size()) << escape_char << value
- << escape_char;
+ *this << escape_char << literal_command << static_cast<std::uint64_t>(value.size())
+ << escape_char << value << escape_char;
}
public:
#include "generate.h"
#include "patch.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace generate_spirv_parser
{
}
try
{
- std::shared_ptr<std::vector<ast::Json_file>> required_files; // outside of try so
+ std::shared_ptr<std::vector<ast::Json_file>> required_files; // outside of try so
try
{
required_files = parser::read_required_files(std::move(input_directory));
int main(int argc, char **argv)
{
- return vulkan_cpu::generate_spirv_parser::generate_spirv_parser_main(argc, argv);
+ return kazan::generate_spirv_parser::generate_spirv_parser_main(argc, argv);
}
*/
#include "instruction_properties.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace generate_spirv_parser
{
#include <cstdint>
#include <cassert>
-namespace vulkan_cpu
+namespace kazan
{
namespace generate_spirv_parser
{
#include <cstdlib>
#include <list>
-namespace vulkan_cpu
+namespace kazan
{
namespace generate_spirv_parser
{
!= 0)
throw Parse_error(top_level_value.location, {}, "file name is unrecognizable");
auto instruction_set_name = file_name;
- instruction_set_name.erase(instruction_set_name.size() - file_name_suffix.size(), file_name_suffix.size());
+ instruction_set_name.erase(instruction_set_name.size() - file_name_suffix.size(),
+ file_name_suffix.size());
instruction_set_name.erase(0, file_name_prefix.size());
if(top_level_value.get_value_kind() != json::ast::Value_kind::object)
throw Parse_error(top_level_value.location, {}, "top level value is not an object");
revision, top_level_value.location, nullptr, "missing revision"),
get_value_or_throw_parse_error(
std::move(instructions), top_level_value.location, nullptr, "missing instructions"));
- std::cerr << "Parsed extension instruction set: " << import_name << " from " << file_name << std::endl;
+ std::cerr << "Parsed extension instruction set: " << import_name << " from " << file_name
+ << std::endl;
return retval;
}
}
#include "json/parser.h"
#include "util/filesystem.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace generate_spirv_parser
{
}
};
-std::shared_ptr<std::vector<ast::Json_file>> read_required_files(const util::filesystem::path &dir_path);
+std::shared_ptr<std::vector<ast::Json_file>> read_required_files(
+ const util::filesystem::path &dir_path);
ast::Top_level parse(std::vector<ast::Json_file> &&json_files);
}
*/
#include "patch.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace generate_spirv_parser
{
#include <ostream>
#include <memory>
-namespace vulkan_cpu
+namespace kazan
{
namespace generate_spirv_parser
{
struct Add_image_operands_grad_parameter_names final : public Ast_patch
{
using Ast_patch::Ast_patch;
+
protected:
virtual bool apply(ast::Top_level &top_level) const override;
#include "util/optional.h"
#include <iterator>
-namespace vulkan_cpu
+namespace kazan
{
namespace generate_spirv_parser
{
#
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
set(sources image.cpp)
-add_library(vulkan_cpu_image STATIC ${sources})
-target_link_libraries(vulkan_cpu_image vulkan_cpu_util vulkan_cpu_llvm_wrapper vulkan_cpu_vulkan)
+add_library(kazan_image STATIC ${sources})
+target_link_libraries(kazan_image kazan_util kazan_llvm_wrapper kazan_vulkan)
#include <cstdint>
#include "util/enum.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace image
{
location.cpp
parser.cpp
source.cpp)
-add_library(vulkan_cpu_json STATIC ${sources})
-target_link_libraries(vulkan_cpu_json vulkan_cpu_util)
+add_library(kazan_json STATIC ${sources})
+target_link_libraries(kazan_json kazan_util)
#include <algorithm>
#include "util/soft_float.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace json
{
#include "util/optional.h"
#include "location.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace json
{
*/
#include "location.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace json
{
#include <string>
#include <iosfwd>
-namespace vulkan_cpu
+namespace kazan
{
namespace json
{
#include <limits>
#include "util/soft_float.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace json
{
#include "location.h"
#include "util/optional.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace json
{
}
}
-#endif /* JSON_PARSER_H_ */
\ No newline at end of file
+#endif /* JSON_PARSER_H_ */
#include <fstream>
#include <algorithm>
-namespace vulkan_cpu
+namespace kazan
{
namespace json
{
#include <iosfwd>
#include "util/filesystem.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace json
{
set(sources llvm_wrapper.cpp
orc_compile_stack.cpp)
-add_library(vulkan_cpu_llvm_wrapper STATIC ${sources})
+add_library(kazan_llvm_wrapper STATIC ${sources})
if(0)
llvm_map_components_to_libnames(llvm_libraries core native analysis orcjit mcjit nativecodegen ipo scalaropts vectorize)
else()
set(llvm_libraries LLVM)
endif()
-target_link_libraries(vulkan_cpu_llvm_wrapper util ${llvm_libraries})
+target_link_libraries(kazan_llvm_wrapper util ${llvm_libraries})
set_source_files_properties(orc_compile_stack.cpp PROPERTIES COMPILE_FLAGS -fno-rtti) # prevent link errors with missing type info
#include <cstdlib>
#include <algorithm>
-namespace vulkan_cpu
+namespace kazan
{
namespace llvm_wrapper
{
#include "util/string_view.h"
#include "util/variant.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace llvm_wrapper
{
#error Orc compile stack is not yet implemented for this version of LLVM
#endif
-namespace vulkan_cpu
+namespace kazan
{
namespace llvm_wrapper
{
}
public:
- void operator()(
- llvm::orc::ObjectLinkingLayerBase::ObjSetHandleT,
- const Object_set_wrapper
- &object_set,
- const std::vector<std::unique_ptr<llvm::RuntimeDyld::LoadedObjectInfo>>
- &load_result)
+ void operator()(llvm::orc::ObjectLinkingLayerBase::ObjSetHandleT,
+ const Object_set_wrapper &object_set,
+ const std::vector<std::unique_ptr<llvm::RuntimeDyld::LoadedObjectInfo>>
+ &load_result)
{
assert(object_set.size() == load_result.size());
for(std::size_t i = 0; i < object_set.size(); i++)
auto retval = create_module_handle();
auto &handle = handle_map[retval];
auto object_set_iter = object_sets.insert(object_sets.end(), std::move(object_set));
- handle = object_linking_layer.addObjectSet(
- Object_set_wrapper(*object_set_iter), std::move(memory_manager), std::move(symbol_resolver));
+ handle = object_linking_layer.addObjectSet(Object_set_wrapper(*object_set_iter),
+ std::move(memory_manager),
+ std::move(symbol_resolver));
return retval;
}
std::vector<std::shared_ptr<llvm::JITEventListener>> jit_event_listener_list;
llvm::orc::ObjectLinkingLayer<On_loaded_functor> object_linking_layer;
std::unordered_map<Module_handle, decltype(object_linking_layer)::ObjSetHandleT> handle_map;
- std::list<std::vector<std::unique_ptr<llvm::object::OwningBinary<llvm::object::ObjectFile>>>> object_sets;
+ std::
+ list<std::vector<std::unique_ptr<llvm::object::OwningBinary<llvm::object::ObjectFile>>>>
+ object_sets;
std::unordered_multiset<const llvm::object::ObjectFile *> loaded_object_set;
};
typedef std::function<std::unique_ptr<llvm::Module>(std::unique_ptr<llvm::Module>)>
#include <utility>
#include <functional>
-namespace vulkan_cpu
+namespace kazan
{
namespace llvm_wrapper
{
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
set(sources pipeline.cpp)
-add_library(vulkan_cpu_pipeline STATIC ${sources})
-target_link_libraries(vulkan_cpu_pipeline vulkan_cpu_spirv_to_llvm
- vulkan_cpu_json
- vulkan_cpu_util
- vulkan_cpu_spirv
- vulkan_cpu_llvm_wrapper
- vulkan_cpu_vulkan
- vulkan_cpu_image)
+add_library(kazan_pipeline STATIC ${sources})
+target_link_libraries(kazan_pipeline kazan_spirv_to_llvm
+ kazan_json
+ kazan_util
+ kazan_spirv
+ kazan_llvm_wrapper
+ kazan_vulkan
+ kazan_image)
#include <vector>
#include <iostream>
-namespace vulkan_cpu
+namespace kazan
{
namespace pipeline
{
std::cerr << dump_callbacks.ss.str() << std::endl;
}
assert(create_info.pVertexInputState);
- assert(create_info.pVertexInputState->sType == VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO);
+ assert(create_info.pVertexInputState->sType
+ == VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO);
auto compiled_shader = spirv_to_llvm::spirv_to_llvm(implementation->llvm_context.get(),
llvm_target_machine.get(),
shader_module->words(),
#include "spirv/spirv.h"
#include "image/image.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace pipeline
{
VERBATIM
COMMENT "Generating SPIR-V Parser")
set(sources ${sources} ${spirv_parser_sources})
-add_library(vulkan_cpu_spirv STATIC ${sources})
-target_link_libraries(vulkan_cpu_spirv vulkan_cpu_util vulkan_cpu_json)
-target_include_directories(vulkan_cpu_spirv PUBLIC ${spirv_parser_generated_include_dir})
+add_library(kazan_spirv STATIC ${sources})
+target_link_libraries(kazan_spirv kazan_util kazan_json)
+target_include_directories(kazan_spirv PUBLIC ${spirv_parser_generated_include_dir})
*/
#include "literal_string.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace spirv
{
#include "util/endian.h"
#include "util/string_view.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace spirv
{
#include <cstdint>
-namespace vulkan_cpu
+namespace kazan
{
namespace spirv
{
opencl_instructions.cpp
spirv_to_llvm.cpp
vertex_entry_point.cpp)
-add_library(vulkan_cpu_spirv_to_llvm STATIC ${sources})
-target_link_libraries(vulkan_cpu_spirv_to_llvm vulkan_cpu_util vulkan_cpu_spirv vulkan_cpu_llvm_wrapper vulkan_cpu_pipeline)
+add_library(kazan_spirv_to_llvm STATIC ${sources})
+target_link_libraries(kazan_spirv_to_llvm kazan_util kazan_spirv kazan_llvm_wrapper kazan_pipeline)
*/
#include "spirv_to_llvm_implementation.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace spirv_to_llvm
{
*/
#include "spirv_to_llvm_implementation.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace spirv_to_llvm
{
if(built_in)
throw Parser_error(
0, 0, "multiple BuiltIn decorations on the same variable");
- built_in =
- util::get<Decoration_built_in_parameters>(decoration.parameters)
- .built_in;
+ built_in = util::get<Decoration_built_in_parameters>(decoration.parameters)
+ .built_in;
continue;
case Decoration::no_perspective:
#warning finish implementing Decoration::no_perspective
#warning finish implementing Decoration::secondary_viewport_relative_nv
break;
}
- throw Parser_error(
- 0,
- 0,
- "unimplemented member decoration on shader input variable: "
- + std::string(get_enumerant_name(decoration.value)));
+ throw Parser_error(0,
+ 0,
+ "unimplemented member decoration on shader input variable: "
+ + std::string(get_enumerant_name(decoration.value)));
}
if(!built_in)
throw Parser_error(
break;
}
throw Parser_error(0,
- 0,
- "unimplemented built in shader input variable: "
- + std::string(get_enumerant_name(*built_in)));
+ 0,
+ "unimplemented built in shader input variable: "
+ + std::string(get_enumerant_name(*built_in)));
} while(false);
}
}
if(location)
throw Parser_error(
0, 0, "multiple Location decorations on the same variable");
- location =
- util::get<Decoration_location_parameters>(decoration.parameters)
- .location;
+ location = util::get<Decoration_location_parameters>(decoration.parameters)
+ .location;
continue;
case Decoration::component:
#warning finish implementing Decoration::component
#warning finish implementing Decoration::secondary_viewport_relative_nv
break;
}
- throw Parser_error(
- 0,
- 0,
- "unimplemented member decoration on shader output variable: "
- + std::string(get_enumerant_name(decoration.value)));
+ throw Parser_error(0,
+ 0,
+ "unimplemented member decoration on shader output variable: "
+ + std::string(get_enumerant_name(decoration.value)));
}
if(!location)
throw Parser_error(
auto callback = [llvm_output_member_type, &output_color, this, output_pointer]()
{
if(output_color)
- throw Parser_error(
- 0, 0, "duplicate fragment shader output variable");
+ throw Parser_error(0, 0, "duplicate fragment shader output variable");
output_color = ::LLVMBuildLoad(builder.get(), output_pointer, "output_color");
::LLVMSetAlignment(output_color, llvm_output_member_type.alignment);
};
*/
#include "spirv_to_llvm_implementation.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace spirv_to_llvm
{
}
}
}
-
*/
#include "spirv_to_llvm_implementation.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace spirv_to_llvm
{
*/
#include "spirv_to_llvm_implementation.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace spirv_to_llvm
{
#include "util/string_view.h"
#include "vulkan/vulkan.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace spirv_to_llvm
{
#include <list>
#include <iostream>
-namespace vulkan_cpu
+namespace kazan
{
namespace spirv_to_llvm
{
generate_code,
};
-vulkan_cpu_util_generate_enum_traits(Stage, Stage::calculate_types, Stage::generate_code);
+kazan_util_generate_enum_traits(Stage, Stage::calculate_types, Stage::generate_code);
static_assert(util::Enum_traits<Stage>::is_compact, "");
#include "spirv_to_llvm_implementation.h"
#include <unordered_map>
-namespace vulkan_cpu
+namespace kazan
{
namespace spirv_to_llvm
{
system_memory_info.cpp
variant.cpp
void_t.cpp)
-add_library(vulkan_cpu_util STATIC ${sources})
-target_include_directories(vulkan_cpu_util PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/..)
-add_executable(vulkan_cpu_util_test EXCLUDE_FROM_ALL ${sources} util_test.cpp)
-target_include_directories(vulkan_cpu_util_test PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/..)
+add_library(kazan_util STATIC ${sources})
+target_include_directories(kazan_util PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/..)
+add_executable(kazan_util_test EXCLUDE_FROM_ALL ${sources} util_test.cpp)
+target_include_directories(kazan_util_test PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/..)
#if defined(__clang__)
#if defined(__apple_build_version__)
#if __clang_major__ > 5 || (__clang_major__ == 5 && __clang_minor__ >= 1)
-#define VULKAN_CPU_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED 1
+#define KAZAN_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED 1
#endif
#else
#if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 4)
-#define VULKAN_CPU_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED 1
+#define KAZAN_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED 1
#endif
#endif
#elif defined(__INTEL_COMPILER)
#warning figure out icc version numbers for constexpr __builtin_clz and __builtin_ctz
#elif defined(__GNUC__)
// gcc supports constexpr __builtin_clz and __builtin_ctz before it supports c++14
-#define VULKAN_CPU_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED 1
+#define KAZAN_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED 1
#endif
#if 1
-#ifdef VULKAN_CPU_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
-#undef VULKAN_CPU_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
+#ifdef KAZAN_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
+#undef KAZAN_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
#endif
#endif
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
constexpr std::uint32_t clz4(std::uint8_t v) noexcept
{
-#ifdef VULKAN_CPU_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
+#ifdef KAZAN_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
return v == 0 ? 4 : __builtin_clz(v) - __builtin_clz(0x8U);
#else
typedef const std::uint_fast8_t LookupTableType[0x10];
constexpr std::uint32_t clz8(std::uint8_t v) noexcept
{
-#ifdef VULKAN_CPU_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
+#ifdef KAZAN_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
return v == 0 ? 8 : __builtin_clz(v) - __builtin_clz(0x80U);
#else
return ((v & 0xF0) == 0) ? 4 + clz4(v) : clz4(v >> 4);
constexpr std::uint32_t clz16(std::uint16_t v) noexcept
{
-#ifdef VULKAN_CPU_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
+#ifdef KAZAN_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
return v == 0 ? 16 : __builtin_clz(v) - (std::numeric_limits<int>::digits - 16);
#else
return ((v & 0xFF00U) == 0) ? 8 + clz8(v) : clz8(v >> 8);
constexpr std::uint32_t clz32(std::uint32_t v) noexcept
{
-#ifdef VULKAN_CPU_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
+#ifdef KAZAN_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
return v == 0 ? 32 : __builtin_clzl(v) - (std::numeric_limits<long>::digits - 32);
#else
return ((v & 0xFFFF0000UL) == 0) ? 16 + clz16(v) : clz16(v >> 16);
constexpr std::uint32_t clz64(std::uint64_t v) noexcept
{
-#ifdef VULKAN_CPU_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
+#ifdef KAZAN_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
return v == 0 ? 64 : __builtin_clzll(v) - (std::numeric_limits<long long>::digits - 64);
#else
return ((v & 0xFFFFFFFF00000000ULL) == 0) ? 32 + clz32(v) : clz32(v >> 32);
constexpr std::uint32_t ctz4(std::uint8_t v) noexcept
{
-#ifdef VULKAN_CPU_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
+#ifdef KAZAN_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
return v == 0 ? 4 : __builtin_ctz(v);
#else
typedef const std::uint_fast8_t LookupTableType[0x10];
constexpr std::uint32_t ctz8(std::uint8_t v) noexcept
{
-#ifdef VULKAN_CPU_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
+#ifdef KAZAN_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
return v == 0 ? 8 : __builtin_ctz(v);
#else
return ((v & 0xF0) == 0) ? ctz4(v) : 4 + ctz4(v >> 4);
constexpr std::uint32_t ctz16(std::uint16_t v) noexcept
{
-#ifdef VULKAN_CPU_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
+#ifdef KAZAN_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
return v == 0 ? 16 : __builtin_ctz(v);
#else
return ((v & 0xFF00U) == 0) ? ctz8(v) : 8 + ctz8(v >> 8);
constexpr std::uint32_t ctz32(std::uint32_t v) noexcept
{
-#ifdef VULKAN_CPU_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
+#ifdef KAZAN_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
return v == 0 ? 32 : __builtin_ctzl(v);
#else
return ((v & 0xFFFF0000UL) == 0) ? ctz16(v) : 16 + ctz16(v >> 16);
constexpr std::uint32_t ctz64(std::uint64_t v) noexcept
{
-#ifdef VULKAN_CPU_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
+#ifdef KAZAN_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
return v == 0 ? 64 : __builtin_ctzll(v);
#else
return ((v & 0xFFFFFFFF00000000ULL) == 0) ? ctz32(v) : 32 + ctz32(v >> 32);
constexpr std::uint32_t popcount8(std::uint8_t v) noexcept
{
-#ifdef VULKAN_CPU_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
+#ifdef KAZAN_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
return __builtin_popcount(v);
#else
constexpr std::uint8_t lookup_table[0x10] = {
constexpr std::uint32_t popcount32(std::uint32_t v) noexcept
{
-#ifdef VULKAN_CPU_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
+#ifdef KAZAN_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
return __builtin_popcountl(v);
#else
constexpr std::uint32_t m1 = 0x5555'5555UL;
constexpr std::uint32_t popcount64(std::uint64_t v) noexcept
{
-#ifdef VULKAN_CPU_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
+#ifdef KAZAN_UTIL_CONSTEXPR_BUILTIN_CLZ_CTZ_POPCOUNT_SUPPORTED
return __builtin_popcountll(v);
#else
constexpr std::uint64_t m1 = 0x5555'5555'5555'5555ULL;
#include <string>
#include <utility>
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
// derived from
// https://github.com/programmerjake/hashlife-voxels/blob/0dd91021a5b9caeffb7849b2114dca89204876bd/util/bitset.h
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
namespace std
{
template <std::size_t Bit_count>
-struct hash<vulkan_cpu::util::bitset<Bit_count>>
+struct hash<kazan::util::bitset<Bit_count>>
{
- constexpr std::size_t operator()(const vulkan_cpu::util::bitset<Bit_count> &v) const noexcept
+ constexpr std::size_t operator()(const kazan::util::bitset<Bit_count> &v) const noexcept
{
return v.hash();
}
#include <iterator>
#include <stdexcept>
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
#ifndef UTIL_COPY_CV_REF_H_
#define UTIL_COPY_CV_REF_H_
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
#include "util/endian_config.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
{
Little,
Big,
- Native = vulkan_cpu_util_endian_endian,
+ Native = kazan_util_endian_endian,
};
constexpr Endian endian = Endian::Native;
#ifndef UTIL_ENDIAN_CONFIG_H_
#define UTIL_ENDIAN_CONFIG_H_
-#define vulkan_cpu_util_endian_endian @UTIL_ENDIAN@
+#define kazan_util_endian_endian @UTIL_ENDIAN@
#endif /* UTIL_ENDIAN_CONFIG_H_ */
-
#include "bitset.h"
#include "is_swappable.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
template <typename Enum, Enum... Values>
constexpr Constexpr_array<Enum, sizeof...(Values)> Default_enum_traits<Enum, Values...>::values;
/** generate code for Enum_traits instantiation; use like
- * <code>vulkan_cpu_util_generate_enum_traits(Enum, Enum::Value1, Enum::Value2, Enum::Value3,
+ * <code>kazan_util_generate_enum_traits(Enum, Enum::Value1, Enum::Value2, Enum::Value3,
* <...>);</code> */
-#define vulkan_cpu_util_generate_enum_traits(Enum, ...) \
- [[gnu::unused]] ::vulkan_cpu::util::detail::Default_enum_traits<Enum, __VA_ARGS__> \
+#define kazan_util_generate_enum_traits(Enum, ...) \
+ [[gnu::unused]] ::kazan::util::detail::Default_enum_traits<Enum, __VA_ARGS__> \
enum_traits_resolve_function(Enum)
}
#error filesystem is not implemented for your operating system
#endif
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
}
#if 0 // change to 1 to test filesystem::path
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
#include <chrono>
#include <ratio>
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
#include <cstddef>
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
#include <functional>
#include "void_t.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
#include <type_traits>
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
#include <type_traits>
#include "is_referenceable.h"
-namespace vulkan_cpu_util_is_swappable_unrelated_namespace
+namespace kazan_util_is_swappable_unrelated_namespace
{
using std::swap;
template <typename T, typename U, bool Is_Void = std::is_void<T>::value || std::is_void<T>::value>
};
}
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
template <typename T, typename U>
struct is_swappable_with
: public std::integral_constant<bool,
- vulkan_cpu_util_is_swappable_unrelated_namespace::
+ kazan_util_is_swappable_unrelated_namespace::
Is_swappable_with<T, U>::value>
{
};
template <typename T, typename U>
struct is_nothrow_swappable_with
: public std::integral_constant<bool,
- vulkan_cpu_util_is_swappable_unrelated_namespace::
+ kazan_util_is_swappable_unrelated_namespace::
Is_nothrow_swappable_with<T, U>::value>
{
};
#include <new>
#include <cstdint>
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
#include "in_place.h"
#include "is_swappable.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
namespace std
{
template <typename T>
-struct hash<vulkan_cpu::util::optional<T>> : public vulkan_cpu::util::detail::optional_hash<T>
+struct hash<kazan::util::optional<T>> : public kazan::util::detail::optional_hash<T>
{
};
}
#include <cstdio>
namespace
{
-using namespace vulkan_cpu::util::soft_float;
+using namespace kazan::util::soft_float;
[[gnu::unused]] std::string hexValue(const ExtendedFloat &v)
{
if(v.isNaN())
#include <cassert>
#include "bit_intrinsics.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
mantissaField |= 0x400U; // add in implicit 1
else
exponentField = 1;
- return ExtendedFloat(mantissaField, static_cast<int>(exponentField) - 15 - 10 + exponentBias() + 63, sign);
+ return ExtendedFloat(
+ mantissaField, static_cast<int>(exponentField) - 15 - 10 + exponentBias() + 63, sign);
}
explicit operator long double() const noexcept
{
#include <stdexcept>
#include <ostream>
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
return a.compare(b) > 0;
}
-#define VULKAN_CPU_UTIL_STRING_VIEW_GENERATE_EXTRA_COMPARE_OPERATORS_NO_ALLOCATOR(...) \
- template <typename Char_type, typename Traits_type> \
- bool operator==(__VA_ARGS__) noexcept \
- { \
- return operator==(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
- static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
- } \
- \
- template <typename Char_type, typename Traits_type> \
- bool operator!=(__VA_ARGS__) noexcept \
- { \
- return operator!=(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
- static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
- } \
- \
- template <typename Char_type, typename Traits_type> \
- bool operator<=(__VA_ARGS__) noexcept \
- { \
- return operator<=(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
- static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
- } \
- \
- template <typename Char_type, typename Traits_type> \
- bool operator>=(__VA_ARGS__) noexcept \
- { \
- return operator>=(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
- static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
- } \
- \
- template <typename Char_type, typename Traits_type> \
- bool operator<(__VA_ARGS__) noexcept \
- { \
- return operator<(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
- static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
- } \
- \
- template <typename Char_type, typename Traits_type> \
- bool operator>(__VA_ARGS__) noexcept \
- { \
- return operator>(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
- static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
+#define KAZAN_UTIL_STRING_VIEW_GENERATE_EXTRA_COMPARE_OPERATORS_NO_ALLOCATOR(...) \
+ template <typename Char_type, typename Traits_type> \
+ bool operator==(__VA_ARGS__) noexcept \
+ { \
+ return operator==(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
+ static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
+ } \
+ \
+ template <typename Char_type, typename Traits_type> \
+ bool operator!=(__VA_ARGS__) noexcept \
+ { \
+ return operator!=(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
+ static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
+ } \
+ \
+ template <typename Char_type, typename Traits_type> \
+ bool operator<=(__VA_ARGS__) noexcept \
+ { \
+ return operator<=(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
+ static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
+ } \
+ \
+ template <typename Char_type, typename Traits_type> \
+ bool operator>=(__VA_ARGS__) noexcept \
+ { \
+ return operator>=(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
+ static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
+ } \
+ \
+ template <typename Char_type, typename Traits_type> \
+ bool operator<(__VA_ARGS__) noexcept \
+ { \
+ return operator<(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
+ static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
+ } \
+ \
+ template <typename Char_type, typename Traits_type> \
+ bool operator>(__VA_ARGS__) noexcept \
+ { \
+ return operator>(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
+ static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
}
-#define VULKAN_CPU_UTIL_STRING_VIEW_GENERATE_EXTRA_COMPARE_OPERATORS_WITH_ALLOCATOR(...) \
- template <typename Char_type, typename Traits_type, typename Allocator> \
- bool operator==(__VA_ARGS__) noexcept \
- { \
- return operator==(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
- static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
- } \
- \
- template <typename Char_type, typename Traits_type, typename Allocator> \
- bool operator!=(__VA_ARGS__) noexcept \
- { \
- return operator!=(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
- static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
- } \
- \
- template <typename Char_type, typename Traits_type, typename Allocator> \
- bool operator<=(__VA_ARGS__) noexcept \
- { \
- return operator<=(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
- static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
- } \
- \
- template <typename Char_type, typename Traits_type, typename Allocator> \
- bool operator>=(__VA_ARGS__) noexcept \
- { \
- return operator>=(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
- static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
- } \
- \
- template <typename Char_type, typename Traits_type, typename Allocator> \
- bool operator<(__VA_ARGS__) noexcept \
- { \
- return operator<(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
- static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
- } \
- \
- template <typename Char_type, typename Traits_type, typename Allocator> \
- bool operator>(__VA_ARGS__) noexcept \
- { \
- return operator>(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
- static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
+#define KAZAN_UTIL_STRING_VIEW_GENERATE_EXTRA_COMPARE_OPERATORS_WITH_ALLOCATOR(...) \
+ template <typename Char_type, typename Traits_type, typename Allocator> \
+ bool operator==(__VA_ARGS__) noexcept \
+ { \
+ return operator==(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
+ static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
+ } \
+ \
+ template <typename Char_type, typename Traits_type, typename Allocator> \
+ bool operator!=(__VA_ARGS__) noexcept \
+ { \
+ return operator!=(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
+ static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
+ } \
+ \
+ template <typename Char_type, typename Traits_type, typename Allocator> \
+ bool operator<=(__VA_ARGS__) noexcept \
+ { \
+ return operator<=(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
+ static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
+ } \
+ \
+ template <typename Char_type, typename Traits_type, typename Allocator> \
+ bool operator>=(__VA_ARGS__) noexcept \
+ { \
+ return operator>=(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
+ static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
+ } \
+ \
+ template <typename Char_type, typename Traits_type, typename Allocator> \
+ bool operator<(__VA_ARGS__) noexcept \
+ { \
+ return operator<(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
+ static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
+ } \
+ \
+ template <typename Char_type, typename Traits_type, typename Allocator> \
+ bool operator>(__VA_ARGS__) noexcept \
+ { \
+ return operator>(static_cast<basic_string_view<Char_type, Traits_type>>(a), \
+ static_cast<basic_string_view<Char_type, Traits_type>>(b)); \
}
-VULKAN_CPU_UTIL_STRING_VIEW_GENERATE_EXTRA_COMPARE_OPERATORS_NO_ALLOCATOR(
+KAZAN_UTIL_STRING_VIEW_GENERATE_EXTRA_COMPARE_OPERATORS_NO_ALLOCATOR(
const Char_type *a, basic_string_view<Char_type, Traits_type> b)
-VULKAN_CPU_UTIL_STRING_VIEW_GENERATE_EXTRA_COMPARE_OPERATORS_NO_ALLOCATOR(
+KAZAN_UTIL_STRING_VIEW_GENERATE_EXTRA_COMPARE_OPERATORS_NO_ALLOCATOR(
basic_string_view<Char_type, Traits_type> a, const Char_type *b)
-VULKAN_CPU_UTIL_STRING_VIEW_GENERATE_EXTRA_COMPARE_OPERATORS_WITH_ALLOCATOR(
+KAZAN_UTIL_STRING_VIEW_GENERATE_EXTRA_COMPARE_OPERATORS_WITH_ALLOCATOR(
basic_string_view<Char_type, Traits_type> a,
std::basic_string<Char_type, Traits_type, Allocator> b)
-VULKAN_CPU_UTIL_STRING_VIEW_GENERATE_EXTRA_COMPARE_OPERATORS_WITH_ALLOCATOR(
+KAZAN_UTIL_STRING_VIEW_GENERATE_EXTRA_COMPARE_OPERATORS_WITH_ALLOCATOR(
std::basic_string<Char_type, Traits_type, Allocator> a,
basic_string_view<Char_type, Traits_type> b)
-#undef VULKAN_CPU_UTIL_STRING_VIEW_GENERATE_EXTRA_COMPARE_OPERATORS_NO_ALLOCATOR
-#undef VULKAN_CPU_UTIL_STRING_VIEW_GENERATE_EXTRA_COMPARE_OPERATORS_WITH_ALLOCATOR
+#undef KAZAN_UTIL_STRING_VIEW_GENERATE_EXTRA_COMPARE_OPERATORS_NO_ALLOCATOR
+#undef KAZAN_UTIL_STRING_VIEW_GENERATE_EXTRA_COMPARE_OPERATORS_WITH_ALLOCATOR
template <typename Char_type, typename Traits_type>
std::basic_ostream<Char_type, Traits_type> &operator<<(
namespace std
{
template <typename Char_type, typename Traits_type>
-struct hash<vulkan_cpu::util::basic_string_view<Char_type, Traits_type>>
+struct hash<kazan::util::basic_string_view<Char_type, Traits_type>>
{
- std::size_t operator()(vulkan_cpu::util::basic_string_view<Char_type, Traits_type> v) const
+ std::size_t operator()(kazan::util::basic_string_view<Char_type, Traits_type> v) const
{
typedef std::basic_string<Char_type, Traits_type> stringType;
return std::hash<stringType>(static_cast<stringType>(v));
#ifdef __linux__
#include <sys/sysinfo.h>
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
#elif defined(_WIN32)
#include <windows.h>
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
#include <cstdint>
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
#include <cassert>
#include "string_view.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
#include <cstdlib>
#include <iostream>
#include <string>
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
#include "is_swappable.h"
#include "invoke.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
using Variant_values =
Variant_values_implementation<variant_is_trivially_destructible<Types...>(), Types...>;
-#define VULKAN_CPU_UTIL_VARIANT_VALUES(Is_Trivially_Destructible, Destructor) \
+#define KAZAN_UTIL_VARIANT_VALUES(Is_Trivially_Destructible, Destructor) \
template <typename T, typename... Types> \
union Variant_values_implementation<Is_Trivially_Destructible, T, Types...> \
{ \
Destructor \
};
-VULKAN_CPU_UTIL_VARIANT_VALUES(true, ~Variant_values_implementation() = default;)
-VULKAN_CPU_UTIL_VARIANT_VALUES(false, ~Variant_values_implementation(){})
-#undef VULKAN_CPU_UTIL_VARIANT_VALUES
+KAZAN_UTIL_VARIANT_VALUES(true, ~Variant_values_implementation() = default;)
+KAZAN_UTIL_VARIANT_VALUES(false, ~Variant_values_implementation(){})
+#undef KAZAN_UTIL_VARIANT_VALUES
template <std::size_t Index, typename... Types>
struct Variant_get;
}
};
-#define VULKAN_CPU_UTIL_VARIANT_DISPATCH(Const, Ref) \
+#define KAZAN_UTIL_VARIANT_DISPATCH(Const, Ref) \
template <std::size_t Index, \
typename Return_Type, \
typename Fn, \
std::forward<Args>(args)...); \
}
-VULKAN_CPU_UTIL_VARIANT_DISPATCH(, &)
-VULKAN_CPU_UTIL_VARIANT_DISPATCH(const, &)
-VULKAN_CPU_UTIL_VARIANT_DISPATCH(, &&)
-VULKAN_CPU_UTIL_VARIANT_DISPATCH(const, &&)
-#undef VULKAN_CPU_UTIL_VARIANT_DISPATCH
+KAZAN_UTIL_VARIANT_DISPATCH(, &)
+KAZAN_UTIL_VARIANT_DISPATCH(const, &)
+KAZAN_UTIL_VARIANT_DISPATCH(, &&)
+KAZAN_UTIL_VARIANT_DISPATCH(const, &&)
+#undef KAZAN_UTIL_VARIANT_DISPATCH
template <std::size_t Type_Count>
struct Variant_index_type
typename... Types>
struct Variant_base;
-#define VULKAN_CPU_UTIL_VARIANT_BASE_DESTRUCTOR_false \
- ~Variant_base() \
- { \
- values.destruct(index_value.get()); \
+#define KAZAN_UTIL_VARIANT_BASE_DESTRUCTOR_false \
+ ~Variant_base() \
+ { \
+ values.destruct(index_value.get()); \
}
-#define VULKAN_CPU_UTIL_VARIANT_BASE_DESTRUCTOR_true ~Variant_base() = default;
+#define KAZAN_UTIL_VARIANT_BASE_DESTRUCTOR_true ~Variant_base() = default;
-#define VULKAN_CPU_UTIL_VARIANT_BASE_COPY_CONSTRUCTOR_true \
+#define KAZAN_UTIL_VARIANT_BASE_COPY_CONSTRUCTOR_true \
Variant_base(const Variant_base &rt) noexcept( \
Variant_values<Types...>::is_nothrow_copy_constructible) \
: values(in_place_index<variant_npos>), index_value(variant_npos) \
index_value = rt.index_value; \
}
-#define VULKAN_CPU_UTIL_VARIANT_BASE_COPY_CONSTRUCTOR_false \
+#define KAZAN_UTIL_VARIANT_BASE_COPY_CONSTRUCTOR_false \
Variant_base(const Variant_base &rt) = delete;
-#define VULKAN_CPU_UTIL_VARIANT_BASE_MOVE_CONSTRUCTOR_true \
+#define KAZAN_UTIL_VARIANT_BASE_MOVE_CONSTRUCTOR_true \
Variant_base(Variant_base &&rt) noexcept( \
Variant_values<Types...>::is_nothrow_move_constructible) \
: values(in_place_index<variant_npos>), index_value(variant_npos) \
index_value = rt.index_value; \
}
-#define VULKAN_CPU_UTIL_VARIANT_BASE_MOVE_CONSTRUCTOR_false \
- Variant_base(Variant_base &&rt) = delete;
+#define KAZAN_UTIL_VARIANT_BASE_MOVE_CONSTRUCTOR_false Variant_base(Variant_base &&rt) = delete;
-#define VULKAN_CPU_UTIL_VARIANT_BASE_COPY_ASSIGN_OP_true \
+#define KAZAN_UTIL_VARIANT_BASE_COPY_ASSIGN_OP_true \
Variant_base &operator=(const Variant_base &rt) noexcept( \
Variant_values<Types...>::is_nothrow_copy_assignable) \
{ \
return *this; \
}
-#define VULKAN_CPU_UTIL_VARIANT_BASE_COPY_ASSIGN_OP_false \
+#define KAZAN_UTIL_VARIANT_BASE_COPY_ASSIGN_OP_false \
Variant_base &operator=(const Variant_base &rt) = delete;
-#define VULKAN_CPU_UTIL_VARIANT_BASE_MOVE_ASSIGN_OP_true \
+#define KAZAN_UTIL_VARIANT_BASE_MOVE_ASSIGN_OP_true \
Variant_base &operator=(Variant_base &&rt) noexcept( \
Variant_values<Types...>::is_nothrow_move_assignable) \
{ \
return *this; \
}
-#define VULKAN_CPU_UTIL_VARIANT_BASE_MOVE_ASSIGN_OP_false \
+#define KAZAN_UTIL_VARIANT_BASE_MOVE_ASSIGN_OP_false \
Variant_base &operator=(Variant_base &&rt) = delete;
-#define VULKAN_CPU_UTIL_VARIANT_BASE0(Is_Trivially_Destructible, \
- Is_Copy_Constructible, \
- Is_Move_Constructible, \
- Is_Copy_Assignable, \
- Is_Move_Assignable) \
- template <typename... Types> \
- struct Variant_base<Is_Trivially_Destructible, \
- Is_Copy_Constructible, \
- Is_Move_Constructible, \
- Is_Copy_Assignable, \
- Is_Move_Assignable, \
- Types...> \
- { \
- Variant_values<Types...> values; \
- Variant_index_type<sizeof...(Types)> index_value; \
- template <typename... Args> \
- constexpr Variant_base( \
- Variant_base_construct_tag, \
- std::size_t index_value, \
- Args &&... args) noexcept(noexcept(new(std::declval<void *>()) \
- Variant_values<Types...>( \
- std::declval<Args>()...))) \
- : values(std::forward<Args>(args)...), index_value(index_value) \
- { \
- } \
- VULKAN_CPU_UTIL_VARIANT_BASE_DESTRUCTOR_##Is_Trivially_Destructible \
- VULKAN_CPU_UTIL_VARIANT_BASE_COPY_CONSTRUCTOR_##Is_Copy_Constructible \
- VULKAN_CPU_UTIL_VARIANT_BASE_MOVE_CONSTRUCTOR_##Is_Move_Constructible \
- VULKAN_CPU_UTIL_VARIANT_BASE_COPY_ASSIGN_OP_##Is_Copy_Assignable \
- VULKAN_CPU_UTIL_VARIANT_BASE_MOVE_ASSIGN_OP_##Is_Move_Assignable \
+#define KAZAN_UTIL_VARIANT_BASE0(Is_Trivially_Destructible, \
+ Is_Copy_Constructible, \
+ Is_Move_Constructible, \
+ Is_Copy_Assignable, \
+ Is_Move_Assignable) \
+ template <typename... Types> \
+ struct Variant_base<Is_Trivially_Destructible, \
+ Is_Copy_Constructible, \
+ Is_Move_Constructible, \
+ Is_Copy_Assignable, \
+ Is_Move_Assignable, \
+ Types...> \
+ { \
+ Variant_values<Types...> values; \
+ Variant_index_type<sizeof...(Types)> index_value; \
+ template <typename... Args> \
+ constexpr Variant_base( \
+ Variant_base_construct_tag, \
+ std::size_t index_value, \
+ Args &&... args) noexcept(noexcept(new(std::declval<void *>()) \
+ Variant_values<Types...>( \
+ std::declval<Args>()...))) \
+ : values(std::forward<Args>(args)...), index_value(index_value) \
+ { \
+ } \
+ KAZAN_UTIL_VARIANT_BASE_DESTRUCTOR_##Is_Trivially_Destructible \
+ KAZAN_UTIL_VARIANT_BASE_COPY_CONSTRUCTOR_##Is_Copy_Constructible \
+ KAZAN_UTIL_VARIANT_BASE_MOVE_CONSTRUCTOR_##Is_Move_Constructible \
+ KAZAN_UTIL_VARIANT_BASE_COPY_ASSIGN_OP_##Is_Copy_Assignable \
+ KAZAN_UTIL_VARIANT_BASE_MOVE_ASSIGN_OP_##Is_Move_Assignable \
};
-#define VULKAN_CPU_UTIL_VARIANT_BASE1( \
+#define KAZAN_UTIL_VARIANT_BASE1( \
Is_Copy_Constructible, Is_Move_Constructible, Is_Copy_Assignable, Is_Move_Assignable) \
- VULKAN_CPU_UTIL_VARIANT_BASE0(false, \
- Is_Copy_Constructible, \
- Is_Move_Constructible, \
- Is_Copy_Assignable, \
- Is_Move_Assignable) \
- VULKAN_CPU_UTIL_VARIANT_BASE0(true, \
- Is_Copy_Constructible, \
- Is_Move_Constructible, \
- Is_Copy_Assignable, \
- Is_Move_Assignable)
-
-#define VULKAN_CPU_UTIL_VARIANT_BASE2( \
- Is_Move_Constructible, Is_Copy_Assignable, Is_Move_Assignable) \
- VULKAN_CPU_UTIL_VARIANT_BASE1( \
- false, Is_Move_Constructible, Is_Copy_Assignable, Is_Move_Assignable) \
- VULKAN_CPU_UTIL_VARIANT_BASE1( \
- true, Is_Move_Constructible, Is_Copy_Assignable, Is_Move_Assignable)
-
-#define VULKAN_CPU_UTIL_VARIANT_BASE3(Is_Copy_Assignable, Is_Move_Assignable) \
- VULKAN_CPU_UTIL_VARIANT_BASE2(false, Is_Copy_Assignable, Is_Move_Assignable) \
- VULKAN_CPU_UTIL_VARIANT_BASE2(true, Is_Copy_Assignable, Is_Move_Assignable)
-
-#define VULKAN_CPU_UTIL_VARIANT_BASE4(Is_Move_Assignable) \
- VULKAN_CPU_UTIL_VARIANT_BASE3(false, Is_Move_Assignable) \
- VULKAN_CPU_UTIL_VARIANT_BASE3(true, Is_Move_Assignable)
-
-VULKAN_CPU_UTIL_VARIANT_BASE4(false)
-VULKAN_CPU_UTIL_VARIANT_BASE4(true)
+ KAZAN_UTIL_VARIANT_BASE0(false, \
+ Is_Copy_Constructible, \
+ Is_Move_Constructible, \
+ Is_Copy_Assignable, \
+ Is_Move_Assignable) \
+ KAZAN_UTIL_VARIANT_BASE0(true, \
+ Is_Copy_Constructible, \
+ Is_Move_Constructible, \
+ Is_Copy_Assignable, \
+ Is_Move_Assignable)
+
+#define KAZAN_UTIL_VARIANT_BASE2(Is_Move_Constructible, Is_Copy_Assignable, Is_Move_Assignable) \
+ KAZAN_UTIL_VARIANT_BASE1(false, Is_Move_Constructible, Is_Copy_Assignable, Is_Move_Assignable) \
+ KAZAN_UTIL_VARIANT_BASE1(true, Is_Move_Constructible, Is_Copy_Assignable, Is_Move_Assignable)
+
+#define KAZAN_UTIL_VARIANT_BASE3(Is_Copy_Assignable, Is_Move_Assignable) \
+ KAZAN_UTIL_VARIANT_BASE2(false, Is_Copy_Assignable, Is_Move_Assignable) \
+ KAZAN_UTIL_VARIANT_BASE2(true, Is_Copy_Assignable, Is_Move_Assignable)
+
+#define KAZAN_UTIL_VARIANT_BASE4(Is_Move_Assignable) \
+ KAZAN_UTIL_VARIANT_BASE3(false, Is_Move_Assignable) \
+ KAZAN_UTIL_VARIANT_BASE3(true, Is_Move_Assignable)
+
+KAZAN_UTIL_VARIANT_BASE4(false)
+KAZAN_UTIL_VARIANT_BASE4(true)
template <typename T>
struct Variant_is_in_place_index
namespace std
{
template <>
-struct hash<vulkan_cpu::util::monostate>
+struct hash<kazan::util::monostate>
{
- constexpr std::size_t operator()(vulkan_cpu::util::monostate) const noexcept
+ constexpr std::size_t operator()(kazan::util::monostate) const noexcept
{
return 5546275UL;
}
};
template <typename... Types>
-struct hash<vulkan_cpu::util::variant<Types...>>
+struct hash<kazan::util::variant<Types...>>
{
- constexpr std::size_t operator()(const vulkan_cpu::util::variant<Types...> &v) const
+ constexpr std::size_t operator()(const kazan::util::variant<Types...> &v) const
{
if(v.valueless_by_exception())
return 10285473UL;
return v.index() * 1414729UL
- + vulkan_cpu::util::visit(
+ + kazan::util::visit(
[](const auto &v) -> std::size_t
{
return std::hash<typename std::decay<decltype(v)>::type>()(v);
}
};
-template <typename... Types,
- typename = typename std::
- enable_if<vulkan_cpu::util::detail::Variant_values<Types...>::is_swappable>::type>
-inline void
- swap(vulkan_cpu::util::variant<Types...> &l, vulkan_cpu::util::variant<Types...> &r) noexcept(
- vulkan_cpu::util::detail::Variant_values<Types...>::is_nothrow_swappable)
+template <
+ typename... Types,
+ typename =
+ typename std::enable_if<kazan::util::detail::Variant_values<Types...>::is_swappable>::type>
+inline void swap(kazan::util::variant<Types...> &l, kazan::util::variant<Types...> &r) noexcept(
+ kazan::util::detail::Variant_values<Types...>::is_nothrow_swappable)
{
l.swap(r);
}
#ifndef UTIL_VOID_T_H_
#define UTIL_VOID_T_H_
-namespace vulkan_cpu
+namespace kazan
{
namespace util
{
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
set(sources vulkan.cpp
api_objects.cpp)
-add_library(vulkan_cpu_vulkan STATIC ${sources})
-target_compile_definitions(vulkan_cpu_vulkan PUBLIC VK_NO_PROTOTYPES)
+add_library(kazan_vulkan STATIC ${sources})
+target_compile_definitions(kazan_vulkan PUBLIC VK_NO_PROTOTYPES)
#include "util/optional.h"
#include <iostream>
-namespace vulkan_cpu
+namespace kazan
{
namespace vulkan
{
#include <cassert>
#include <chrono>
-namespace vulkan_cpu
+namespace kazan
{
namespace vulkan
{
Not_supported,
};
-vulkan_cpu_util_generate_enum_traits(Supported_extension, Supported_extension::Not_supported);
+kazan_util_generate_enum_traits(Supported_extension, Supported_extension::Not_supported);
typedef util::Enum_set<Supported_extension> Supported_extensions;
.vendorID = 0x12345678UL,
.deviceID = 0,
.deviceType = VK_PHYSICAL_DEVICE_TYPE_CPU,
- .deviceName = "Vulkan-CPU Device",
+ .deviceName = "Kazan Software Renderer",
#warning calculate the correct value of pipelineCacheUUID as the hash of the target cpu info and the hashed source code
.pipelineCacheUUID = {},
.limits =
#include "spirv/spirv.h"
#include "util/enum.h"
-namespace vulkan_cpu
+namespace kazan
{
namespace vulkan
{
#
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
set(sources vulkan_icd.cpp)
-add_library(vulkan_cpu_vulkan_icd MODULE ${sources})
-target_link_libraries(vulkan_cpu_vulkan_icd
- vulkan_cpu_vulkan
- vulkan_cpu_util)
-file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/vulkan_cpu_vulkan_icd.json INPUT ${CMAKE_CURRENT_SOURCE_DIR}/vulkan_cpu_vulkan_icd.json.in)
+add_library(kazan_vulkan_icd MODULE ${sources})
+target_link_libraries(kazan_vulkan_icd
+ kazan_vulkan
+ kazan_util)
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/kazan_vulkan_icd.json INPUT ${CMAKE_CURRENT_SOURCE_DIR}/kazan_vulkan_icd.json.in)
if(UNIX AND NOT CYGWIN)
- target_link_libraries(vulkan_cpu_vulkan_icd -Wl,--no-undefined)
+ target_link_libraries(kazan_vulkan_icd -Wl,--no-undefined)
endif()
--- /dev/null
+{
+ "file_format_version": "1.0.0",
+ "ICD": {
+ "library_path": "$<TARGET_FILE:kazan_vulkan_icd>",
+ "api_version": "1.0.58"
+ }
+}
+++ /dev/null
-{
- "file_format_version": "1.0.0",
- "ICD": {
- "library_path": "$<TARGET_FILE:vulkan_cpu_vulkan_icd>",
- "api_version": "1.0.58"
- }
-}
#include <initializer_list>
#include <iostream>
-using namespace vulkan_cpu;
+using namespace kazan;
#ifdef __ELF__
#define DLLEXPORT_ATTR(original_attributes) \
#warning finish implementing vkCmdExecuteCommands
assert(!"vkCmdExecuteCommands is not implemented");
}
-namespace vulkan_cpu
+namespace kazan
{
namespace vulkan_icd
{
typedef PFN_vkVoidFunction (*VKAPI_PTR PFN_vk_icdGetInstanceProcAddr)(VkInstance instance,
const char *pName);
-namespace vulkan_cpu
+namespace kazan
{
namespace vulkan_icd
{