diff --git a/CMakeLists.txt b/CMakeLists.txt index e00a9f33..c26e642f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,8 +20,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows") include_directories(${Vulkan_INCLUDE_DIRS}) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdpty/jsoncpp/include) - add_subdirectory(3rdpty/jsoncpp) +# include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdpty/jsoncpp/include) +# add_subdirectory(3rdpty/jsoncpp) elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR) elseif(UNIX) @@ -56,7 +56,7 @@ SET(ULRE ULRE.Base ULRE.Platform MathGeoLib spirv-cross-core - jsoncpp_lib +# jsoncpp_lib ${RENDER_LIBRARY} ${Vulkan_LIBRARIES}) diff --git a/example/Vulkan/main.cpp b/example/Vulkan/main.cpp index 24cf43d8..40f3b21a 100644 --- a/example/Vulkan/main.cpp +++ b/example/Vulkan/main.cpp @@ -106,17 +106,17 @@ private: { constexpr os_char PIPELINE_FILENAME[]=OS_TEXT("2DSolid.pipeline"); - //{ - // vulkan::PipelineCreater *pipeline_creater=new vulkan::PipelineCreater(device,material,device->GetRenderPass(),device->GetExtent()); - // pipeline_creater->SetDepthTest(false); - // pipeline_creater->SetDepthWrite(false); - // pipeline_creater->CloseCullFace(); - // pipeline_creater->Set(PRIM_TRIANGLES); + { + vulkan::PipelineCreater *pipeline_creater=new vulkan::PipelineCreater(device,material,device->GetRenderPass(),device->GetExtent()); + pipeline_creater->SetDepthTest(false); + pipeline_creater->SetDepthWrite(false); + pipeline_creater->CloseCullFace(); + pipeline_creater->Set(PRIM_TRIANGLES); - // SaveToFile(PIPELINE_FILENAME,pipeline_creater); + SaveToFile(PIPELINE_FILENAME,pipeline_creater); - // delete pipeline_creater; - //} + delete pipeline_creater; + } { void *data; diff --git a/inc/hgl/io/MemoryInputStream.h b/inc/hgl/io/MemoryInputStream.h index 78edbbe9..589f7dcf 100644 --- a/inc/hgl/io/MemoryInputStream.h +++ b/inc/hgl/io/MemoryInputStream.h @@ -1,7 +1,6 @@ #ifndef HGL_IO_MEMORY_INPUT_STREAM_INCLUDE #define HGL_IO_MEMORY_INPUT_STREAM_INCLUDE -#include #include namespace hgl { diff --git a/inc/hgl/io/MemoryOutputStream.h b/inc/hgl/io/MemoryOutputStream.h index 6378d28f..cdd528d7 100644 --- a/inc/hgl/io/MemoryOutputStream.h +++ b/inc/hgl/io/MemoryOutputStream.h @@ -1,7 +1,6 @@ #ifndef HGL_IO_MEMORY_OUTPUT_STREAM_INCLUDE #define HGL_IO_MEMORY_OUTPUT_STREAM_INCLUDE -#include #include namespace hgl { diff --git a/src/RenderDevice/Vulkan/POD/VKPipelineCreateInfo.POD.cpp b/src/RenderDevice/Vulkan/POD/VKPipelineCreateInfo.POD.cpp index df6d637d..3a84770b 100644 --- a/src/RenderDevice/Vulkan/POD/VKPipelineCreateInfo.POD.cpp +++ b/src/RenderDevice/Vulkan/POD/VKPipelineCreateInfo.POD.cpp @@ -9,35 +9,37 @@ using namespace hgl; VK_NAMESPACE_BEGIN + +#define WRITE_AND_CHECK_SIZE(ptr,type) if(dos->Write(ptr,sizeof(type))!=sizeof(type))return(false); + bool PipelineCreater::SaveToStream(io::DataOutputStream *dos) { if(!dos)return(false); - dos->WriteUint16(1); //file ver + if(!dos->WriteUint16(1))return(false); //file ver - dos->Write(&pipelineInfo,sizeof(VkGraphicsPipelineCreateInfo)); + WRITE_AND_CHECK_SIZE(&pipelineInfo,VkGraphicsPipelineCreateInfo); + WRITE_AND_CHECK_SIZE(pipelineInfo.pInputAssemblyState, VkPipelineInputAssemblyStateCreateInfo ); + WRITE_AND_CHECK_SIZE(pipelineInfo.pTessellationState, VkPipelineTessellationStateCreateInfo ); + WRITE_AND_CHECK_SIZE(pipelineInfo.pRasterizationState, VkPipelineRasterizationStateCreateInfo ); - dos->Write(pipelineInfo.pInputAssemblyState, sizeof(VkPipelineInputAssemblyStateCreateInfo)); - dos->Write(pipelineInfo.pTessellationState, sizeof(VkPipelineTessellationStateCreateInfo)); - dos->Write(pipelineInfo.pRasterizationState, sizeof(VkPipelineRasterizationStateCreateInfo)); - - dos->Write(pipelineInfo.pMultisampleState, sizeof(VkPipelineMultisampleStateCreateInfo)); + WRITE_AND_CHECK_SIZE(pipelineInfo.pMultisampleState, VkPipelineMultisampleStateCreateInfo ); if(pipelineInfo.pMultisampleState->pSampleMask) { const uint count=(pipelineInfo.pMultisampleState->rasterizationSamples+31)/32; - dos->WriteUint8(count); - dos->WriteUint32(pipelineInfo.pMultisampleState->pSampleMask,count); + if(!dos->WriteUint8(count))return(false); + if(dos->WriteUint32(pipelineInfo.pMultisampleState->pSampleMask,count)!=count)return(false); } else { - dos->WriteUint8(0); + if(!dos->WriteUint8(0))return(false); } - dos->Write(pipelineInfo.pDepthStencilState, sizeof(VkPipelineDepthStencilStateCreateInfo)); + WRITE_AND_CHECK_SIZE(pipelineInfo.pDepthStencilState, VkPipelineDepthStencilStateCreateInfo); - dos->Write(pipelineInfo.pColorBlendState,sizeof(VkPipelineColorBlendStateCreateInfo)); + WRITE_AND_CHECK_SIZE(pipelineInfo.pColorBlendState, VkPipelineColorBlendStateCreateInfo); for(uint32_t i=0;iattachmentCount;i++) - dos->Write(pipelineInfo.pColorBlendState->pAttachments+i,sizeof(VkPipelineColorBlendAttachmentState)); + WRITE_AND_CHECK_SIZE(pipelineInfo.pColorBlendState->pAttachments+i,VkPipelineColorBlendAttachmentState); return(true); } diff --git a/src/RenderDevice/Vulkan/VKPipeline.cpp b/src/RenderDevice/Vulkan/VKPipeline.cpp index 1c2be942..689005ff 100644 --- a/src/RenderDevice/Vulkan/VKPipeline.cpp +++ b/src/RenderDevice/Vulkan/VKPipeline.cpp @@ -77,7 +77,12 @@ PipelineCreater::PipelineCreater(Device *dev,const Material *material,RenderPass pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; InitVertexInputState(material); - pipelineInfo.pTessellationState=nullptr; + tessellation.sType=VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; + tessellation.pNext=nullptr; + tessellation.flags=0; + tessellation.patchControlPoints=0; + + pipelineInfo.pTessellationState=&tessellation; InitViewportState();