增加PipelineCreateInfo.POD
This commit is contained in:
parent
d4bd590485
commit
6ea1e699b0
@ -7,7 +7,7 @@
|
||||
using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
|
||||
void SaveToJSON(const OSString &filename,const VkGraphicsPipelineCreateInfo *info);
|
||||
bool SaveToFile(const OSString &filename,const VkGraphicsPipelineCreateInfo *info);
|
||||
|
||||
constexpr uint32_t SCREEN_WIDTH=128;
|
||||
constexpr uint32_t SCREEN_HEIGHT=128;
|
||||
@ -102,18 +102,25 @@ private:
|
||||
|
||||
bool InitPipeline()
|
||||
{
|
||||
vulkan::PipelineCreater *
|
||||
pipeline_creater=new vulkan::PipelineCreater(device,material,device->GetRenderPass());
|
||||
pipeline_creater->SetDepthTest(false);
|
||||
pipeline_creater->SetDepthWrite(false);
|
||||
pipeline_creater->CloseCullFace();
|
||||
pipeline_creater->Set(PRIM_TRIANGLES);
|
||||
constexpr os_char PIPELINE_FILENAME[]=OS_TEXT("2DSolid.pipeline");
|
||||
|
||||
//vulkan::PipelineCreater *pipeline_creater=new vulkan::PipelineCreater(device,material,device->GetRenderPass());
|
||||
//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());
|
||||
|
||||
pipeline=pipeline_creater->Create();
|
||||
|
||||
SaveToJSON(OS_TEXT("pipeline.json"),pipeline_creater->GetInfo());
|
||||
SaveToFile(PIPELINE_FILENAME,pipeline_creater->GetInfo());
|
||||
|
||||
delete pipeline_creater;
|
||||
delete pipeline;
|
||||
|
||||
|
||||
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ namespace hgl
|
||||
* @param len 存放数据长度的指针
|
||||
* @return 创建好的内存拷贝
|
||||
*/
|
||||
void *CreateCopyData(int *len)const
|
||||
void *CreateCopyData(uint *len)const
|
||||
{
|
||||
if(buf_size<=0)
|
||||
return(nullptr);
|
||||
|
@ -48,13 +48,12 @@ SET(RENDER_DEVICE_VULKAN_SOURCE VKFormat.cpp
|
||||
VKMaterial.cpp
|
||||
VKRenderable.cpp)
|
||||
|
||||
#SET(RENDER_DEVICE_VULKAN_TOML_SOURCE toml/VKPipelineCreateInfo.TOML.cpp)
|
||||
SET(RENDER_DEVICE_VULKAN_JSON_SOURCE json/VKPipelineCreateInfo.JSON.cpp)
|
||||
SET(RENDER_DEVICE_VULKAN_POD_SOURCE pod/VKPipelineCreateInfo.POD.cpp)
|
||||
|
||||
SOURCE_GROUP("Header Files" FILES ${RENDER_DEVICE_VULKAN_HEADER})
|
||||
SOURCE_GROUP("Source Files" FILES ${RENDER_DEVICE_VULKAN_SOURCE})
|
||||
SOURCE_GROUP("JSON Source Files" FILES ${RENDER_DEVICE_VULKAN_JSON_SOURCE})
|
||||
SOURCE_GROUP("POD Source Files" FILES ${RENDER_DEVICE_VULKAN_POD_SOURCE})
|
||||
|
||||
add_library(ULRE.RenderDevice.Vulkan STATIC ${RENDER_DEVICE_VULKAN_HEADER}
|
||||
${RENDER_DEVICE_VULKAN_SOURCE}
|
||||
${RENDER_DEVICE_VULKAN_JSON_SOURCE})
|
||||
${RENDER_DEVICE_VULKAN_POD_SOURCE})
|
||||
|
52
src/RenderDevice/Vulkan/POD/VKPipelineCreateInfo.POD.cpp
Normal file
52
src/RenderDevice/Vulkan/POD/VKPipelineCreateInfo.POD.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
#include<vulkan/vulkan.h>
|
||||
#include<hgl/type/BaseString.h>
|
||||
#include<hgl/io/MemoryOutputStream.h>
|
||||
#include<hgl/io/DataOutputStream.h>
|
||||
#include<hgl/filesystem/FileSystem.h>
|
||||
|
||||
using namespace hgl;
|
||||
|
||||
namespace
|
||||
{
|
||||
void Write(io::DataOutputStream *dos,const VkPipelineMultisampleStateCreateInfo *info)
|
||||
{
|
||||
dos->Write(info);
|
||||
|
||||
if(info->pSampleMask)
|
||||
dos->WriteUint32(info->pSampleMask,(info->rasterizationSamples+31)/32);
|
||||
}
|
||||
|
||||
void Write(io::DataOutputStream *dos,const VkPipelineColorBlendStateCreateInfo *info)
|
||||
{
|
||||
dos->Write(info,sizeof(VkPipelineColorBlendStateCreateInfo));
|
||||
|
||||
for(uint32_t i=0;i<info->attachmentCount;i++)
|
||||
dos->Write(info->pAttachments+i,sizeof(VkPipelineColorBlendAttachmentState));
|
||||
}
|
||||
}//namespace
|
||||
|
||||
bool SaveToFile(const OSString &filename,const VkGraphicsPipelineCreateInfo *info)
|
||||
{
|
||||
if(filename.IsEmpty()||!info)
|
||||
return(false);
|
||||
|
||||
io::MemoryOutputStream mos;
|
||||
io::DataOutputStream *dos=new io::LEDataOutputStream(&mos);
|
||||
|
||||
dos->WriteUint16(1); //file ver
|
||||
|
||||
dos->Write(info,sizeof(VkGraphicsPipelineCreateInfo));
|
||||
|
||||
dos->Write(info->pInputAssemblyState, sizeof(VkPipelineInputAssemblyStateCreateInfo));
|
||||
dos->Write(info->pTessellationState, sizeof(VkPipelineTessellationStateCreateInfo));
|
||||
dos->Write(info->pRasterizationState, sizeof(VkPipelineRasterizationStateCreateInfo));
|
||||
Write(dos,info->pMultisampleState);
|
||||
dos->Write(info->pDepthStencilState, sizeof(VkPipelineDepthStencilStateCreateInfo));
|
||||
Write(dos,info->pColorBlendState);
|
||||
|
||||
delete dos;
|
||||
|
||||
filesystem::SaveMemoryToFile(filename,mos.GetData(),mos.Tell());
|
||||
|
||||
return(true);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user