From e7ed72d6e272927f53f8a930ec860e7f6eeb0363 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Thu, 17 Sep 2020 21:56:16 +0800 Subject: [PATCH] add .material version check. --- example/Vulkan/Atomsphere.cpp | 2 +- src/RenderDevice/Vulkan/CMakeLists.txt | 4 +- .../Vulkan/VKShaderModuleManage.cpp | 3 + src/SceneGraph/InlineGeometry.cpp | 138 +++++++++--------- 4 files changed, 75 insertions(+), 72 deletions(-) diff --git a/example/Vulkan/Atomsphere.cpp b/example/Vulkan/Atomsphere.cpp index b5150fe6..697ad512 100644 --- a/example/Vulkan/Atomsphere.cpp +++ b/example/Vulkan/Atomsphere.cpp @@ -42,7 +42,7 @@ private: bool InitMaterial() { - material=shader_manage->CreateMaterial(OS_TEXT("res/material/Atmosphere")); + material=shader_manage->CreateMaterial(OS_TEXT("res/material/Atmosphere")); //不需要写.material的扩展名 if(!material) return(false); diff --git a/src/RenderDevice/Vulkan/CMakeLists.txt b/src/RenderDevice/Vulkan/CMakeLists.txt index e98e2daf..cba578d3 100644 --- a/src/RenderDevice/Vulkan/CMakeLists.txt +++ b/src/RenderDevice/Vulkan/CMakeLists.txt @@ -46,6 +46,8 @@ SOURCE_GROUP("Descriptor Sets" FILES ${VK_DESCRIPTOR_SETS_SOURCE}) SET(VK_SHADER_SOURCE ${RD_INCLUDE_PATH}/VKShaderModule.h ${RD_INCLUDE_PATH}/VKShaderModuleManage.h + ${RD_INCLUDE_PATH}/ShaderModuleMap.h + ShaderModuleMap.cpp VKShaderModule.cpp VKShaderModuleManage.cpp) @@ -59,8 +61,6 @@ SET(VK_TEXTURE_SOURCE ${RD_INCLUDE_PATH}/VKImageView.h SET(VK_MATERIAL_SOURCE ${RD_INCLUDE_PATH}/VKMaterial.h ${RD_INCLUDE_PATH}/VKMaterialInstance.h - ${RD_INCLUDE_PATH}/ShaderModuleMap.h - ShaderModuleMap.cpp VKMaterial.cpp VKMaterialInstance.cpp) diff --git a/src/RenderDevice/Vulkan/VKShaderModuleManage.cpp b/src/RenderDevice/Vulkan/VKShaderModuleManage.cpp index 03fe60a7..e9ec9b42 100644 --- a/src/RenderDevice/Vulkan/VKShaderModuleManage.cpp +++ b/src/RenderDevice/Vulkan/VKShaderModuleManage.cpp @@ -231,6 +231,9 @@ Material *ShaderModuleManage::CreateMaterial(const OSString &filename) ++sp; --left; + if(ver!=1) + return(nullptr); + const uint32_t shader_bits=*(uint32_t *)sp; sp+=sizeof(uint32_t); left-=sizeof(uint32_t); diff --git a/src/SceneGraph/InlineGeometry.cpp b/src/SceneGraph/InlineGeometry.cpp index 3265047d..6a79df21 100644 --- a/src/SceneGraph/InlineGeometry.cpp +++ b/src/SceneGraph/InlineGeometry.cpp @@ -709,7 +709,7 @@ namespace hgl for (i = 0; i < numberSlices; i++) { - *tp = centerIndex; ++tp; + *tp = centerIndex; ++tp; *tp = indexCounter; ++tp; *tp = indexCounter + 1; ++tp; @@ -723,7 +723,7 @@ namespace hgl for (i = 0; i < numberSlices; i++) { - *tp = centerIndex; ++tp; + *tp = centerIndex; ++tp; *tp = indexCounter + 1; ++tp; *tp = indexCounter; ++tp; @@ -734,11 +734,11 @@ namespace hgl // Sides for (i = 0; i < numberSlices; i++) { - *tp = indexCounter; ++tp; + *tp = indexCounter; ++tp; *tp = indexCounter + 1; ++tp; *tp = indexCounter + 2; ++tp; - *tp = indexCounter + 2; ++tp; + *tp = indexCounter + 2; ++tp; *tp = indexCounter + 1; ++tp; *tp = indexCounter + 3; ++tp; @@ -802,11 +802,11 @@ namespace hgl for(uint i = 0; i < cci->numberSlices + 1; i++) { - float currentAngle = angleStep * (float)i; + float currentAngle = angleStep * (float)i; - *vp = cos(currentAngle) * cci->radius; ++vp; - *vp = -sin(currentAngle) * cci->radius; ++vp; - *vp = -cci->halfExtend; ++vp; + *vp = cos(currentAngle) * cci->radius; ++vp; + *vp = -sin(currentAngle) * cci->radius; ++vp; + *vp = -cci->halfExtend; ++vp; if(np) { @@ -855,11 +855,11 @@ namespace hgl for(uint i = 0; i < cci->numberSlices + 1; i++) { - float currentAngle = angleStep * (float)i; + float currentAngle = angleStep * (float)i; - *vp = cos(currentAngle) * cci->radius; ++vp; - *vp = -sin(currentAngle) * cci->radius; ++vp; - *vp = cci->halfExtend; ++vp; + *vp = cos(currentAngle) * cci->radius; ++vp; + *vp = -sin(currentAngle) * cci->radius; ++vp; + *vp = cci->halfExtend; ++vp; if(np) { @@ -884,37 +884,37 @@ namespace hgl for(uint i = 0; i < cci->numberSlices + 1; i++) { - float currentAngle = angleStep * (float)i; + float currentAngle = angleStep * (float)i; - float sign = -1.0f; + float sign = -1.0f; - for (uint j = 0; j < 2; j++) + for (uint j = 0; j < 2; j++) { - *vp = cos(currentAngle) * cci->radius; ++vp; - *vp = -sin(currentAngle) * cci->radius; ++vp; - *vp = cci->halfExtend * sign; ++vp; + *vp = cos(currentAngle) * cci->radius; ++vp; + *vp = -sin(currentAngle) * cci->radius; ++vp; + *vp = cci->halfExtend * sign; ++vp; if(np) { - *np = cos(currentAngle); ++np; - *np = -sin(currentAngle); ++np; - *np = 0.0f; ++np; + *np = cos(currentAngle); ++np; + *np = -sin(currentAngle); ++np; + *np = 0.0f; ++np; } if(tp) { - *tp = -sin(currentAngle); ++tp; - *tp = -cos(currentAngle); ++tp; - *tp = 0.0f; ++tp; + *tp = -sin(currentAngle); ++tp; + *tp = -cos(currentAngle); ++tp; + *tp = 0.0f; ++tp; } if(tcp) { - *tcp = (float)i / (float)cci->numberSlices; ++tcp; - *tcp = (sign + 1.0f) / 2.0f; ++tcp; + *tcp = (float)i / (float)cci->numberSlices; ++tcp; + *tcp = (sign + 1.0f) / 2.0f; ++tcp; } - sign = 1.0f; + sign = 1.0f; } } @@ -938,7 +938,7 @@ namespace hgl for (i = 0; i < numberSlices; i++) { - *tp = centerIndex; ++tp; + *tp = centerIndex; ++tp; *tp = indexCounter; ++tp; *tp = indexCounter + 1; ++tp; @@ -947,21 +947,21 @@ namespace hgl indexCounter++; // Sides - for (j = 0; j < numberStacks; j++) - { - for (i = 0; i < numberSlices; i++) - { - *tp = indexCounter; ++tp; - *tp = indexCounter + numberSlices + 1; ++tp; - *tp = indexCounter + 1; ++tp; + for (j = 0; j < numberStacks; j++) + { + for (i = 0; i < numberSlices; i++) + { + *tp = indexCounter; ++tp; + *tp = indexCounter + numberSlices + 1; ++tp; + *tp = indexCounter + 1; ++tp; - *tp = indexCounter + 1; ++tp; - *tp = indexCounter + numberSlices + 1; ++tp; - *tp = indexCounter + numberSlices + 2; ++tp; + *tp = indexCounter + 1; ++tp; + *tp = indexCounter + numberSlices + 1; ++tp; + *tp = indexCounter + numberSlices + 2; ++tp; - indexCounter++; - } - indexCounter++; + indexCounter++; + } + indexCounter++; } } }//namespace @@ -1024,63 +1024,63 @@ namespace hgl for (i = 0; i < cci->numberSlices + 1; i++) { - float currentAngle = angleStep * (float)i; + float currentAngle = angleStep * (float)i; - *vp = cos(currentAngle) * cci->radius; ++vp; - *vp = -sin(currentAngle) * cci->radius; ++vp; - *vp = -cci->halfExtend; ++vp; + *vp = cos(currentAngle) * cci->radius; ++vp; + *vp = -sin(currentAngle) * cci->radius; ++vp; + *vp = -cci->halfExtend; ++vp; if(np) { - *np = 0.0f;++np; - *np = 0.0f;++np; - *np =-1.0f;++np; + *np = 0.0f;++np; + *np = 0.0f;++np; + *np =-1.0f;++np; } if(tp) { - *tp = sin(currentAngle); ++tp; - *tp = cos(currentAngle); ++tp; - *tp = 0.0f; ++tp; + *tp = sin(currentAngle); ++tp; + *tp = cos(currentAngle); ++tp; + *tp = 0.0f; ++tp; } if(tcp) { - *tcp = 0.0f; ++tcp; - *tcp = 0.0f; ++tcp; + *tcp = 0.0f; ++tcp; + *tcp = 0.0f; ++tcp; } } - for (j = 0; j < cci->numberStacks + 1; j++) + for (j = 0; j < cci->numberStacks + 1; j++) { - float level = (float)j / (float)cci->numberStacks; + float level = (float)j / (float)cci->numberStacks; - for (i = 0; i < cci->numberSlices + 1; i++) - { - float currentAngle = angleStep * (float)i; + for (i = 0; i < cci->numberSlices + 1; i++) + { + float currentAngle = angleStep * (float)i; - *vp = cos(currentAngle) * cci->radius * (1.0f - level); ++vp; - *vp = -sin(currentAngle) * cci->radius * (1.0f - level); ++vp; - *vp = -cci->halfExtend + 2.0f * cci->halfExtend * level; ++vp; + *vp = cos(currentAngle) * cci->radius * (1.0f - level); ++vp; + *vp = -sin(currentAngle) * cci->radius * (1.0f - level); ++vp; + *vp = -cci->halfExtend + 2.0f * cci->halfExtend * level; ++vp; if(np) { - *np = h / l * cos(currentAngle); ++np; - *np = h / l * -sin(currentAngle); ++np; - *np = r / l; ++np; + *np = h / l * cos(currentAngle); ++np; + *np = h / l * -sin(currentAngle); ++np; + *np = r / l; ++np; } if(tp) { - *tp = -sin(currentAngle); ++tp; - *tp = -cos(currentAngle); ++tp; - *tp = 0.0f; ++tp; + *tp = -sin(currentAngle); ++tp; + *tp = -cos(currentAngle); ++tp; + *tp = 0.0f; ++tp; } if(tcp) { - *tcp = (float)i / (float)cci->numberSlices; ++tcp; - *tcp = level; ++tcp; + *tcp = (float)i / (float)cci->numberSlices; ++tcp; + *tcp = level; ++tcp; } } }