update
This commit is contained in:
parent
702b15225c
commit
90c6998e44
@ -169,8 +169,6 @@ namespace api {
|
|||||||
mFileFlags = *res;
|
mFileFlags = *res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SetFileFlag(".hello", 1);
|
|
||||||
SaveFileFlags();
|
|
||||||
}
|
}
|
||||||
void ResourceSystemImpl::SaveFileFlags()
|
void ResourceSystemImpl::SaveFileFlags()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -22,10 +22,13 @@ namespace api
|
|||||||
|
|
||||||
USING_OVERLOAD_CTOR(Guid, string_view)
|
USING_OVERLOAD_CTOR(Guid, string_view)
|
||||||
UFUNCTION({}, ref = USING_CTOR_NAME)
|
UFUNCTION({}, ref = USING_CTOR_NAME)
|
||||||
Guid(string_view str) noexcept
|
Guid(string_view str) noexcept : Guid{str.data()} {}
|
||||||
|
USING_OVERLOAD_CTOR(Guid, const char*)
|
||||||
|
UFUNCTION({}, ref = USING_CTOR_NAME)
|
||||||
|
Guid(const char* str) noexcept
|
||||||
: Guid{}
|
: Guid{}
|
||||||
{
|
{
|
||||||
sscanf_s(str.data(),
|
sscanf_s(str,
|
||||||
"%8x-%4hx-%4hx-%2hhx%2hhx-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx",
|
"%8x-%4hx-%4hx-%2hhx%2hhx-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx",
|
||||||
&Data1, &Data2, &Data3,
|
&Data1, &Data2, &Data3,
|
||||||
&Data4[0], &Data4[1], &Data4[2], &Data4[3],
|
&Data4[0], &Data4[1], &Data4[2], &Data4[3],
|
||||||
|
|||||||
@ -2,6 +2,17 @@
|
|||||||
#include "meta/result.h"
|
#include "meta/result.h"
|
||||||
#include "json/serialize.inl"
|
#include "json/serialize.inl"
|
||||||
#include "json/serde.inl"
|
#include "json/serde.inl"
|
||||||
|
namespace gen {
|
||||||
|
template<>
|
||||||
|
inline bool JsonRead<refl::Any>(yyjson_val* node, const refl::Any& t) {
|
||||||
|
if (!node) return false;
|
||||||
|
return api::JsonArchive::Deserialize(node, t);
|
||||||
|
}
|
||||||
|
template<>
|
||||||
|
inline yyjson_mut_val* JsonWrite<refl::Any>(yyjson_mut_doc* doc, const refl::Any& t) {
|
||||||
|
return api::JsonArchive::Serialize(doc, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
namespace api {
|
namespace api {
|
||||||
using meta::result;
|
using meta::result;
|
||||||
using std::string_view;
|
using std::string_view;
|
||||||
|
|||||||
@ -49,7 +49,12 @@ namespace gen {
|
|||||||
return yyjson_mut_real(doc, *(T*)(ptr));
|
return yyjson_mut_real(doc, *(T*)(ptr));
|
||||||
}
|
}
|
||||||
else if constexpr (is_string_v<T>) {
|
else if constexpr (is_string_v<T>) {
|
||||||
return yyjson_mut_str(doc, ((T*)ptr)->data());
|
if constexpr (requires(T * t) { t->data(); }) {
|
||||||
|
return yyjson_mut_str(doc, ((T*)ptr)->data());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return yyjson_mut_str(doc, std::string(*(T*)ptr).data());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//static_assert(false, "unknown json write type");
|
//static_assert(false, "unknown json write type");
|
||||||
|
|||||||
@ -33,43 +33,40 @@ namespace gen {
|
|||||||
using value_type_t = typename T::value_type;
|
using value_type_t = typename T::value_type;
|
||||||
T& docker = *(T*)ptr;
|
T& docker = *(T*)ptr;
|
||||||
size_t length = yyjson_arr_size(val);
|
size_t length = yyjson_arr_size(val);
|
||||||
char data[sizeof(value_type_t)];
|
value_type_t it;//构造失败怎么办?
|
||||||
for (size_t i = 0; i < length; ++i) {
|
for (size_t i = 0; i < length; ++i) {
|
||||||
yyjson_val* obj_i = yyjson_arr_get(val, i);
|
yyjson_val* obj_i = yyjson_arr_get(val, i);
|
||||||
if constexpr (refl::is_map_v<T>) {
|
if constexpr (refl::is_map_v<T>) {
|
||||||
using key_type = refl::detail::is_pair<value_type_t>::key_type;
|
using key_type = refl::detail::is_pair<value_type_t>::key_type;
|
||||||
using value_type = refl::detail::is_pair<value_type_t>::value_type;
|
using value_type = refl::detail::is_pair<value_type_t>::value_type;
|
||||||
key_type& key = *(key_type*)data;
|
JsonRead(yyjson_obj_get(obj_i, "#k"), it.first);
|
||||||
value_type& value = *(value_type*)(data + sizeof(key_type));
|
JsonRead(yyjson_obj_get(obj_i, "#v"), it.second);
|
||||||
JsonRead(yyjson_obj_get(obj_i, "#k"), key);
|
docker[it.first] = it.second;
|
||||||
JsonRead(yyjson_obj_get(obj_i, "#v"), value);
|
|
||||||
docker[key] = value;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
value_type_t& obj = (value_type_t*)data;
|
JsonRead(obj_i, it);
|
||||||
JsonRead(obj_i, obj);
|
docker.push_back(it);
|
||||||
docker.push_back(obj);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
inline static yyjson_mut_val* Write(yyjson_mut_doc* doc, const void* ptr) {
|
inline static yyjson_mut_val* Write(yyjson_mut_doc* doc, const void* ptr) {
|
||||||
T& docker = *(T*)ptr;
|
T& docker = *(T*)ptr;
|
||||||
|
yyjson_mut_val* arr = yyjson_mut_arr(doc);
|
||||||
if constexpr (refl::is_map_v<T>) {
|
if constexpr (refl::is_map_v<T>) {
|
||||||
yyjson_mut_val* obj = yyjson_mut_obj(doc);
|
|
||||||
for (auto& it : docker) {
|
for (auto& it : docker) {
|
||||||
|
yyjson_mut_val* obj = yyjson_mut_obj(doc);
|
||||||
yyjson_mut_obj_add_val(doc, obj, "#k", JsonWrite(doc, it.first));
|
yyjson_mut_obj_add_val(doc, obj, "#k", JsonWrite(doc, it.first));
|
||||||
yyjson_mut_obj_add_val(doc, obj, "#v", JsonWrite(doc, it.second));
|
yyjson_mut_obj_add_val(doc, obj, "#v", JsonWrite(doc, it.second));
|
||||||
|
yyjson_mut_arr_add_val(arr, obj);
|
||||||
}
|
}
|
||||||
return obj;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
yyjson_mut_val* arr = yyjson_mut_arr(doc);
|
|
||||||
for (auto& it : docker) {
|
for (auto& it : docker) {
|
||||||
yyjson_mut_arr_add_val(doc, JsonWrite(doc, it));
|
yyjson_mut_arr_add_val(arr, JsonWrite(doc, it));
|
||||||
}
|
}
|
||||||
return arr;
|
|
||||||
}
|
}
|
||||||
|
return arr;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,4 +44,5 @@ namespace api {
|
|||||||
UPROPERTY_vk()
|
UPROPERTY_vk()
|
||||||
uint32_t BoneIDs[MAX_NUM_BONES_PER_VERTEX] = {};
|
uint32_t BoneIDs[MAX_NUM_BONES_PER_VERTEX] = {};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
#include ".render/vertex_gen.inl"
|
||||||
@ -1,4 +1,7 @@
|
|||||||
static_component("render","engine")
|
static_component("render","engine")
|
||||||
|
add_rules("c++.codegen",{
|
||||||
|
files = {"include/render/asset/*.h"}
|
||||||
|
})
|
||||||
add_includedirs("3rdparty", {public = true})
|
add_includedirs("3rdparty", {public = true})
|
||||||
add_headerfiles("include/**.h", "include/**.inl")
|
add_headerfiles("include/**.h", "include/**.inl")
|
||||||
add_files("src/**.cpp")
|
add_files("src/**.cpp")
|
||||||
|
|||||||
@ -23,6 +23,7 @@ namespace pmr
|
|||||||
Name(std::string_view str)noexcept;
|
Name(std::string_view str)noexcept;
|
||||||
auto operator<=>(const Name& other) const noexcept { return hash <=> other.hash; };
|
auto operator<=>(const Name& other) const noexcept { return hash <=> other.hash; };
|
||||||
bool operator==(const Name& other) const {return hash == other.hash;}
|
bool operator==(const Name& other) const {return hash == other.hash;}
|
||||||
|
bool operator==(size_t _hash) {return hash == _hash;}
|
||||||
const char* data()const { return ToStringView().data(); }
|
const char* data()const { return ToStringView().data(); }
|
||||||
constexpr size_t Hash() const noexcept { return hash; }
|
constexpr size_t Hash() const noexcept { return hash; }
|
||||||
std::string ToString() const;
|
std::string ToString() const;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#include "convert.h"
|
#include "convert.h"
|
||||||
namespace refl {
|
namespace refl {
|
||||||
ConvertMapWrap::ConvertMapWrap() : table(Convert::BuildConvertMap()){}
|
inline ConvertMapWrap::ConvertMapWrap() : table(Convert::BuildConvertMap()){}
|
||||||
template<typename From, typename To>
|
template<typename From, typename To>
|
||||||
inline bool refl::Convert::ConvertTo(Any& to, const Any& from)
|
inline bool refl::Convert::ConvertTo(Any& to, const Any& from)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -43,7 +43,24 @@ namespace refl {
|
|||||||
const UClass* type{};
|
const UClass* type{};
|
||||||
Data data{};
|
Data data{};
|
||||||
uint32_t flag{};
|
uint32_t flag{};
|
||||||
|
Offset GetOffset() const {
|
||||||
|
if (flag & FIELD_ATTRIBUTE_FLAG) {
|
||||||
|
return data.member.offset;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Any GetValue()const {
|
||||||
|
if (flag & FIELD_ATTRIBUTE_FLAG)
|
||||||
|
return data.member.value;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
Any GetMeta()const {
|
||||||
|
if (flag & FIELD_ATTRIBUTE_FLAG)
|
||||||
|
return data.member.meta;
|
||||||
|
if (flag & FIELD_METHOD_FLAG)
|
||||||
|
return data.method.meta;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
template<typename Func, typename... Args>
|
template<typename Func, typename... Args>
|
||||||
auto Call(Func func, Args&&... args)const;
|
auto Call(Func func, Args&&... args)const;
|
||||||
template<bool IsSafeMemory = false>
|
template<bool IsSafeMemory = false>
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
#include "uclass.h"
|
#include "uclass.h"
|
||||||
namespace refl {
|
namespace refl {
|
||||||
span<Any> MakeAnyArgs(span<Any> args, span<const UClass*> params, pmr::memory_resource* alloc = MetaGlobalPool()) {
|
inline span<Any> MakeAnyArgs(span<Any> args, span<const UClass*> params, pmr::memory_resource* alloc = MetaGlobalPool()) {
|
||||||
size_t clsIndex = params.size() - args.size();
|
size_t clsIndex = params.size() - args.size();
|
||||||
assert(clsIndex > 0);
|
assert(clsIndex > 0);
|
||||||
span<const UClass*> subParams = params.subspan(clsIndex);
|
span<const UClass*> subParams = params.subspan(clsIndex);
|
||||||
|
|||||||
@ -145,6 +145,13 @@ namespace refl {
|
|||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
const UClass* GetMeta(Name name)const {
|
||||||
|
auto func = vtable.GetMeta();
|
||||||
|
if (func) {
|
||||||
|
return func(name);
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
bool IsChildOf(const UClass* cls, bool bthis = false) const {
|
bool IsChildOf(const UClass* cls, bool bthis = false) const {
|
||||||
const UClass* _parent = bthis ? this : parent;
|
const UClass* _parent = bthis ? this : parent;
|
||||||
while (_parent != nullptr) {
|
while (_parent != nullptr) {
|
||||||
|
|||||||
@ -26,6 +26,9 @@ namespace refl {
|
|||||||
else {
|
else {
|
||||||
vtable.AddConstruct(&UClass::Construct<T>);
|
vtable.AddConstruct(&UClass::Construct<T>);
|
||||||
vtable.AddDestruct(&UClass::Destruct<T>);
|
vtable.AddDestruct(&UClass::Destruct<T>);
|
||||||
|
if constexpr (is_metas_v<T>) {
|
||||||
|
vtable.AddGetMeta(&Meta<T>::GetMeta);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -170,6 +173,9 @@ namespace refl {
|
|||||||
if constexpr (has_parent_v<T>) {
|
if constexpr (has_parent_v<T>) {
|
||||||
parent = meta_info<parent_t<T>>();
|
parent = meta_info<parent_t<T>>();
|
||||||
}
|
}
|
||||||
|
if constexpr (is_metas_v<T>) {
|
||||||
|
vtable.AddGetMeta(&Meta<T>::GetMeta);
|
||||||
|
}
|
||||||
vtable.AddGetFields(&UClass_Meta::GetFields);
|
vtable.AddGetFields(&UClass_Meta::GetFields);
|
||||||
vtable.AddConstruct(&UClass::Construct<T>);
|
vtable.AddConstruct(&UClass::Construct<T>);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,4 +4,5 @@ header_component("zlib","engine")
|
|||||||
if is_mode("debug") then
|
if is_mode("debug") then
|
||||||
add_defines("API_DEBUG", {public = true})
|
add_defines("API_DEBUG", {public = true})
|
||||||
end
|
end
|
||||||
|
add_syslinks("kernel32")
|
||||||
set_pcheader("include/refl/pch.h")
|
set_pcheader("include/refl/pch.h")
|
||||||
@ -5,6 +5,7 @@
|
|||||||
#include "vkn/wrapper/device.h"
|
#include "vkn/wrapper/device.h"
|
||||||
#include "vkn/thread/buffer_worker.h"
|
#include "vkn/thread/buffer_worker.h"
|
||||||
#include "vkn/thread/command_worker.h"
|
#include "vkn/thread/command_worker.h"
|
||||||
|
#include "vkn/loader/vulkan_glsl_loader.h"
|
||||||
#include "render/asset/mesh.h"
|
#include "render/asset/mesh.h"
|
||||||
#include "meta/enum.h"
|
#include "meta/enum.h"
|
||||||
#include "tinyimageformat/tinyimageformat_apis.h"
|
#include "tinyimageformat/tinyimageformat_apis.h"
|
||||||
@ -77,6 +78,167 @@ namespace vkn {
|
|||||||
}
|
}
|
||||||
void VulkanAPI::LoadShader(Shader& shader)
|
void VulkanAPI::LoadShader(Shader& shader)
|
||||||
{
|
{
|
||||||
|
pmr::vector<VkPipelineShaderStageCreateInfo> shaderStages;
|
||||||
|
std::map<VkShaderStageFlagBits, VkShaderModule> shaderModules;
|
||||||
|
auto& device = backend.GetDevice();
|
||||||
|
auto vertModule = shader.GetVertHandle<vkShaderProgram>()->Ptr();
|
||||||
|
shaderModules.insert(std::make_pair(VK_SHADER_STAGE_VERTEX_BIT, vertModule));
|
||||||
|
auto fragModule = shader.GetFragHandle<vkShaderProgram>()->Ptr();
|
||||||
|
shaderModules.insert(std::make_pair(VK_SHADER_STAGE_FRAGMENT_BIT, fragModule));
|
||||||
|
for (auto& shaderModule : shaderModules)
|
||||||
|
{
|
||||||
|
VkPipelineShaderStageCreateInfo shaderStageInfo = {};
|
||||||
|
shaderStageInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
||||||
|
shaderStageInfo.stage = shaderModule.first;
|
||||||
|
shaderStageInfo.module = shaderModule.second;
|
||||||
|
shaderStageInfo.pName = "main";
|
||||||
|
shaderStages.push_back(shaderStageInfo);
|
||||||
|
}
|
||||||
|
auto it = refl::find_info(shader.Name());
|
||||||
|
auto meta = it->GetMeta("vkMeta");
|
||||||
|
// 设置顶点输入格式
|
||||||
|
VkPipelineVertexInputStateCreateInfo vertexInputInfo = {};
|
||||||
|
VkVertexInputBindingDescription bindingDescription = {};
|
||||||
|
bindingDescription.binding = 0;
|
||||||
|
bindingDescription.stride = meta->size;
|
||||||
|
bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
|
||||||
|
//这里顶点属性不能大余16
|
||||||
|
std::array<VkVertexInputAttributeDescription, 16> attributeDescriptions = { };
|
||||||
|
{
|
||||||
|
uint32_t count = 0;
|
||||||
|
for (auto& field : meta->GetFields(refl::FIND_ALL_MEMBER, Name(""))) {
|
||||||
|
auto& attr = attributeDescriptions[count];
|
||||||
|
attr.binding = 0;
|
||||||
|
attr.location = count++;
|
||||||
|
attr.format = field.GetMeta() ? (VkFormat)field.GetMeta().CastTo<uint32_t>() : VK_FORMAT_R32G32B32_SFLOAT;
|
||||||
|
attr.offset = field.GetOffset();
|
||||||
|
}
|
||||||
|
vertexInputInfo.vertexAttributeDescriptionCount = count;
|
||||||
|
}
|
||||||
|
vertexInputInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
|
||||||
|
vertexInputInfo.pVertexBindingDescriptions = &bindingDescription;
|
||||||
|
vertexInputInfo.pVertexAttributeDescriptions = attributeDescriptions.data();
|
||||||
|
vertexInputInfo.vertexBindingDescriptionCount = 1;
|
||||||
|
|
||||||
|
// 设置图元
|
||||||
|
VkPipelineInputAssemblyStateCreateInfo inputAssemblyInfo = {};
|
||||||
|
inputAssemblyInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
|
||||||
|
inputAssemblyInfo.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
|
||||||
|
inputAssemblyInfo.primitiveRestartEnable = VK_FALSE;
|
||||||
|
|
||||||
|
// ViewPort信息,这里不直接设置,下面弄成动态的
|
||||||
|
VkPipelineViewportStateCreateInfo viewportStateInfo = {};
|
||||||
|
viewportStateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
|
||||||
|
viewportStateInfo.viewportCount = 1;
|
||||||
|
viewportStateInfo.scissorCount = 1;
|
||||||
|
|
||||||
|
// View Port和Scissor设置为动态,每帧绘制时决定
|
||||||
|
pmr::vector<VkDynamicState> dynamicStates = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR };
|
||||||
|
VkPipelineDynamicStateCreateInfo dynamicStateInfo = {};
|
||||||
|
dynamicStateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
|
||||||
|
dynamicStateInfo.pDynamicStates = dynamicStates.data();
|
||||||
|
dynamicStateInfo.dynamicStateCount = static_cast<uint32_t>(dynamicStates.size());
|
||||||
|
|
||||||
|
// 设置光栅化阶段
|
||||||
|
VkPipelineRasterizationStateCreateInfo rasterizationInfo = {};
|
||||||
|
rasterizationInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
|
||||||
|
// 如果depthClampEnable设置为VK_TRUE,超过远近裁剪面的片元会进行收敛,而不是丢弃它们
|
||||||
|
rasterizationInfo.depthClampEnable = VK_FALSE;
|
||||||
|
// 如果rasterizerDiscardEnable设置为VK_TRUE,那么几何图元永远不会传递到光栅化阶段
|
||||||
|
// 这是禁止任何数据输出到framebuffer的方法
|
||||||
|
rasterizationInfo.rasterizerDiscardEnable = VK_FALSE;
|
||||||
|
// 设置片元如何从几何模型中产生,如果不是FILL,需要开启GPU feature
|
||||||
|
// VK_POLYGON_MODE_FILL: 多边形区域填充
|
||||||
|
// VK_POLYGON_MODE_LINE: 多边形边缘线框绘制
|
||||||
|
// VK_POLYGON_MODE_POINT : 多边形顶点作为描点绘制
|
||||||
|
rasterizationInfo.polygonMode = VK_POLYGON_MODE_FILL;
|
||||||
|
rasterizationInfo.lineWidth = 1.0f;
|
||||||
|
rasterizationInfo.cullMode = VK_CULL_MODE_FRONT_BIT;
|
||||||
|
rasterizationInfo.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE;
|
||||||
|
// 渲染阴影的偏移配置
|
||||||
|
rasterizationInfo.depthBiasEnable = VK_FALSE;
|
||||||
|
rasterizationInfo.depthBiasConstantFactor = 0.0f;
|
||||||
|
rasterizationInfo.depthBiasClamp = 0.0f;
|
||||||
|
rasterizationInfo.depthBiasSlopeFactor = 0.0f;
|
||||||
|
|
||||||
|
// 设置Shader采样纹理的MSAA(不是输出到屏幕上的MSAA),需要创建逻辑设备的时候开启VkPhysicalDeviceFeatures里的sampleRateShading才能生效,暂时关闭
|
||||||
|
VkPipelineMultisampleStateCreateInfo multisampleInfo = {};
|
||||||
|
multisampleInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
|
||||||
|
multisampleInfo.sampleShadingEnable = (VK_SAMPLE_COUNT_1_BIT & VK_SAMPLE_COUNT_1_BIT ? VK_FALSE : VK_TRUE);
|
||||||
|
multisampleInfo.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
|
||||||
|
// 这个是调整sampleShading效果的,越接近1效果越平滑,越接近0性能越好
|
||||||
|
multisampleInfo.minSampleShading = 1.0f;
|
||||||
|
multisampleInfo.pSampleMask = VK_NULL_HANDLE;
|
||||||
|
multisampleInfo.alphaToCoverageEnable = VK_FALSE;
|
||||||
|
multisampleInfo.alphaToOneEnable = VK_FALSE;
|
||||||
|
|
||||||
|
// Color Blend
|
||||||
|
VkPipelineColorBlendAttachmentState colorBlendAttachment{};
|
||||||
|
colorBlendAttachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
|
||||||
|
colorBlendAttachment.blendEnable = VK_TRUE;
|
||||||
|
colorBlendAttachment.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
|
||||||
|
colorBlendAttachment.dstColorBlendFactor = VK_BLEND_FACTOR_ONE;
|
||||||
|
colorBlendAttachment.colorBlendOp = VK_BLEND_OP_ADD;
|
||||||
|
colorBlendAttachment.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
|
||||||
|
colorBlendAttachment.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
|
||||||
|
colorBlendAttachment.alphaBlendOp = VK_BLEND_OP_ADD;
|
||||||
|
VkPipelineColorBlendStateCreateInfo colorBlending{};
|
||||||
|
colorBlending.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
|
||||||
|
colorBlending.logicOpEnable = VK_FALSE;
|
||||||
|
colorBlending.logicOp = VK_LOGIC_OP_COPY;
|
||||||
|
colorBlending.pAttachments = &colorBlendAttachment;
|
||||||
|
colorBlending.attachmentCount = 1;
|
||||||
|
|
||||||
|
// 深度和模板配置
|
||||||
|
VkPipelineDepthStencilStateCreateInfo depthStencilInfo = {};
|
||||||
|
depthStencilInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
|
||||||
|
// Depth
|
||||||
|
depthStencilInfo.depthWriteEnable = VK_FALSE;
|
||||||
|
depthStencilInfo.depthTestEnable = VK_TRUE;
|
||||||
|
depthStencilInfo.depthCompareOp = VK_COMPARE_OP_LESS;
|
||||||
|
depthStencilInfo.depthBoundsTestEnable = VK_FALSE;
|
||||||
|
depthStencilInfo.minDepthBounds = 0.0f;
|
||||||
|
depthStencilInfo.maxDepthBounds = 1.0f;
|
||||||
|
// Stencil
|
||||||
|
depthStencilInfo.stencilTestEnable = VK_FALSE;
|
||||||
|
depthStencilInfo.front = {};
|
||||||
|
depthStencilInfo.back = {};
|
||||||
|
/*
|
||||||
|
auto descriptorSetLayout = VulkanContext::CreateDescriptorSetLayout(shader.GetInfo());
|
||||||
|
auto pipelineLayout = VulkanContext::CreatePipelineLayout({ descriptorSetLayout }, {});
|
||||||
|
|
||||||
|
VkGraphicsPipelineCreateInfo pipelineInfo{};
|
||||||
|
pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
|
||||||
|
pipelineInfo.pStages = shaderStages.data();
|
||||||
|
pipelineInfo.stageCount = (uint32_t)shaderStages.size();
|
||||||
|
pipelineInfo.pVertexInputState = &vertexInputInfo;
|
||||||
|
pipelineInfo.pInputAssemblyState = &inputAssemblyInfo;
|
||||||
|
pipelineInfo.pViewportState = &viewportStateInfo;
|
||||||
|
pipelineInfo.pDynamicState = &dynamicStateInfo;
|
||||||
|
pipelineInfo.pRasterizationState = &rasterizationInfo;
|
||||||
|
pipelineInfo.pMultisampleState = &multisampleInfo;
|
||||||
|
pipelineInfo.pColorBlendState = &colorBlending;
|
||||||
|
pipelineInfo.pDepthStencilState = nullptr; //&depthStencilInfo;
|
||||||
|
pipelineInfo.layout = pipelineLayout;
|
||||||
|
pipelineInfo.renderPass = PassList[RENDER_FORWARD_RENDERING]->Ptr();
|
||||||
|
pipelineInfo.subpass = 0;
|
||||||
|
pipelineInfo.basePipelineHandle = VK_NULL_HANDLE;
|
||||||
|
pipelineInfo.basePipelineIndex = -1;
|
||||||
|
|
||||||
|
VkPipeline pipeLine;
|
||||||
|
if (vkCreateGraphicsPipelines(device.Ptr(), VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &pipeLine) != VK_SUCCESS)
|
||||||
|
throw std::runtime_error("failed to create graphics pipeline!");
|
||||||
|
|
||||||
|
for (auto& shaderModule : shaderModules)
|
||||||
|
vkDestroyShaderModule(device.Ptr(), shaderModule.second, nullptr);
|
||||||
|
|
||||||
|
VulkanPipeline& vulkan_pipeline = PipelineTable[shader.GetGuid()];
|
||||||
|
vulkan_pipeline.name = shader.Name();
|
||||||
|
vulkan_pipeline.pipeline = pipeLine;
|
||||||
|
vulkan_pipeline.inUse = true;
|
||||||
|
vulkan_pipeline.pipelineLayout = pipelineLayout;
|
||||||
|
vulkan_pipeline.descriptorSetLayout = descriptorSetLayout;
|
||||||
|
vulkan_pipeline.descriptorSet = backend.GetPool().Allocate(descriptorSetLayout);*/
|
||||||
}
|
}
|
||||||
ImagePtr VulkanAPI::CreateTexture(TextureDesc desc)
|
ImagePtr VulkanAPI::CreateTexture(TextureDesc desc)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -96,6 +96,7 @@ namespace vkn {
|
|||||||
throw std::runtime_error("Failed to wait for fence!");
|
throw std::runtime_error("Failed to wait for fence!");
|
||||||
vkAcquireNextImageKHR(mDevice.Ptr(), mPtr, UINT64_MAX, surfaceSemaphore, VK_NULL_HANDLE, &ctx.presentFrame);
|
vkAcquireNextImageKHR(mDevice.Ptr(), mPtr, UINT64_MAX, surfaceSemaphore, VK_NULL_HANDLE, &ctx.presentFrame);
|
||||||
vkResetFences(mDevice.Ptr(), 1, &surfaceFence);
|
vkResetFences(mDevice.Ptr(), 1, &surfaceFence);
|
||||||
|
ctx.presentFrame = ctx.presentFrame % mFrames;
|
||||||
}
|
}
|
||||||
void VulkanSwapchain::Present(VulkanContext& ctx)
|
void VulkanSwapchain::Present(VulkanContext& ctx)
|
||||||
{
|
{
|
||||||
@ -134,4 +135,5 @@ namespace vkn {
|
|||||||
.maxFrameInFlightCount = 2
|
.maxFrameInFlightCount = 2
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#include ".render/vertex_gen.inl"
|
||||||
@ -1,7 +1,5 @@
|
|||||||
#include "refl/pch.h"
|
#include "refl/pch.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace refl;
|
|
||||||
using namespace std;
|
|
||||||
namespace api {
|
namespace api {
|
||||||
struct Guid {
|
struct Guid {
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
@ -9,11 +7,11 @@ namespace api {
|
|||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
float b;
|
float b;
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
string view;
|
std::string view;
|
||||||
USING_OVERLOAD_CTOR(Guid, int , float)
|
USING_OVERLOAD_CTOR(Guid, int , float)
|
||||||
UFUNCTION({}, ref = USING_CTOR_NAME)
|
UFUNCTION({}, ref = USING_CTOR_NAME)
|
||||||
Guid(int aa, float bb) :a(aa), b(bb), view("default") {
|
Guid(int aa, float bb) :a(aa), b(bb), view("default") {
|
||||||
cout << view << endl;
|
std::cout << view << std::endl;
|
||||||
}
|
}
|
||||||
UFUNCTION({})
|
UFUNCTION({})
|
||||||
int Multy(int c)const {
|
int Multy(int c)const {
|
||||||
|
|||||||
@ -4,17 +4,19 @@
|
|||||||
#define CORE_API_VAL
|
#define CORE_API_VAL
|
||||||
#include "archive/json.h"
|
#include "archive/json.h"
|
||||||
#include "test_refl.h"
|
#include "test_refl.h"
|
||||||
#include <os/file_handle.h>
|
|
||||||
using namespace api;
|
using namespace api;
|
||||||
|
using namespace std;
|
||||||
|
using namespace refl;
|
||||||
int main() {
|
int main() {
|
||||||
table<uint32_t, string> t1, t2;
|
using TestContainer = vector<Name>;
|
||||||
t1[1] = "hello";
|
TestContainer t1, t2;
|
||||||
t1[2] = "world";
|
t1.push_back("hello");
|
||||||
|
t1.push_back("world");
|
||||||
|
//t1[1] = "hello";
|
||||||
|
//t1[2] = "world";
|
||||||
|
|
||||||
auto text = JsonSerialize(t1);
|
auto text = JsonSerialize(t1);
|
||||||
FileHandle handle("test.txt");
|
auto res = JsonDeserialize<TestContainer>(text);
|
||||||
handle.Open(FILE_OP::WRITE, false);
|
|
||||||
handle.Write(text);
|
|
||||||
auto res = JsonDeserialize<table<uint32_t, string>>(text);
|
|
||||||
if (res) {
|
if (res) {
|
||||||
t2 = *res;
|
t2 = *res;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user