PipelineCreateInfo.POD增加安全性检测
This commit is contained in:
parent
88a9fdf9cb
commit
a84fd2b970
@ -20,8 +20,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|||||||
|
|
||||||
include_directories(${Vulkan_INCLUDE_DIRS})
|
include_directories(${Vulkan_INCLUDE_DIRS})
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdpty/jsoncpp/include)
|
# include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdpty/jsoncpp/include)
|
||||||
add_subdirectory(3rdpty/jsoncpp)
|
# add_subdirectory(3rdpty/jsoncpp)
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||||
add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR)
|
add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR)
|
||||||
elseif(UNIX)
|
elseif(UNIX)
|
||||||
@ -56,7 +56,7 @@ SET(ULRE ULRE.Base
|
|||||||
ULRE.Platform
|
ULRE.Platform
|
||||||
MathGeoLib
|
MathGeoLib
|
||||||
spirv-cross-core
|
spirv-cross-core
|
||||||
jsoncpp_lib
|
# jsoncpp_lib
|
||||||
${RENDER_LIBRARY}
|
${RENDER_LIBRARY}
|
||||||
${Vulkan_LIBRARIES})
|
${Vulkan_LIBRARIES})
|
||||||
|
|
||||||
|
@ -106,17 +106,17 @@ private:
|
|||||||
{
|
{
|
||||||
constexpr os_char PIPELINE_FILENAME[]=OS_TEXT("2DSolid.pipeline");
|
constexpr os_char PIPELINE_FILENAME[]=OS_TEXT("2DSolid.pipeline");
|
||||||
|
|
||||||
//{
|
{
|
||||||
// vulkan::PipelineCreater *pipeline_creater=new vulkan::PipelineCreater(device,material,device->GetRenderPass(),device->GetExtent());
|
vulkan::PipelineCreater *pipeline_creater=new vulkan::PipelineCreater(device,material,device->GetRenderPass(),device->GetExtent());
|
||||||
// pipeline_creater->SetDepthTest(false);
|
pipeline_creater->SetDepthTest(false);
|
||||||
// pipeline_creater->SetDepthWrite(false);
|
pipeline_creater->SetDepthWrite(false);
|
||||||
// pipeline_creater->CloseCullFace();
|
pipeline_creater->CloseCullFace();
|
||||||
// pipeline_creater->Set(PRIM_TRIANGLES);
|
pipeline_creater->Set(PRIM_TRIANGLES);
|
||||||
|
|
||||||
// SaveToFile(PIPELINE_FILENAME,pipeline_creater);
|
SaveToFile(PIPELINE_FILENAME,pipeline_creater);
|
||||||
|
|
||||||
// delete pipeline_creater;
|
delete pipeline_creater;
|
||||||
//}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
void *data;
|
void *data;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef HGL_IO_MEMORY_INPUT_STREAM_INCLUDE
|
#ifndef HGL_IO_MEMORY_INPUT_STREAM_INCLUDE
|
||||||
#define HGL_IO_MEMORY_INPUT_STREAM_INCLUDE
|
#define HGL_IO_MEMORY_INPUT_STREAM_INCLUDE
|
||||||
|
|
||||||
#include<hgl/type/MemBlock.h>
|
|
||||||
#include<hgl/io/InputStream.h>
|
#include<hgl/io/InputStream.h>
|
||||||
namespace hgl
|
namespace hgl
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef HGL_IO_MEMORY_OUTPUT_STREAM_INCLUDE
|
#ifndef HGL_IO_MEMORY_OUTPUT_STREAM_INCLUDE
|
||||||
#define HGL_IO_MEMORY_OUTPUT_STREAM_INCLUDE
|
#define HGL_IO_MEMORY_OUTPUT_STREAM_INCLUDE
|
||||||
|
|
||||||
#include<hgl/type/MemBlock.h>
|
|
||||||
#include<hgl/io/OutputStream.h>
|
#include<hgl/io/OutputStream.h>
|
||||||
namespace hgl
|
namespace hgl
|
||||||
{
|
{
|
||||||
|
@ -9,35 +9,37 @@
|
|||||||
using namespace hgl;
|
using namespace hgl;
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
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)
|
bool PipelineCreater::SaveToStream(io::DataOutputStream *dos)
|
||||||
{
|
{
|
||||||
if(!dos)return(false);
|
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));
|
WRITE_AND_CHECK_SIZE(pipelineInfo.pMultisampleState, VkPipelineMultisampleStateCreateInfo );
|
||||||
dos->Write(pipelineInfo.pTessellationState, sizeof(VkPipelineTessellationStateCreateInfo));
|
|
||||||
dos->Write(pipelineInfo.pRasterizationState, sizeof(VkPipelineRasterizationStateCreateInfo));
|
|
||||||
|
|
||||||
dos->Write(pipelineInfo.pMultisampleState, sizeof(VkPipelineMultisampleStateCreateInfo));
|
|
||||||
if(pipelineInfo.pMultisampleState->pSampleMask)
|
if(pipelineInfo.pMultisampleState->pSampleMask)
|
||||||
{
|
{
|
||||||
const uint count=(pipelineInfo.pMultisampleState->rasterizationSamples+31)/32;
|
const uint count=(pipelineInfo.pMultisampleState->rasterizationSamples+31)/32;
|
||||||
dos->WriteUint8(count);
|
if(!dos->WriteUint8(count))return(false);
|
||||||
dos->WriteUint32(pipelineInfo.pMultisampleState->pSampleMask,count);
|
if(dos->WriteUint32(pipelineInfo.pMultisampleState->pSampleMask,count)!=count)return(false);
|
||||||
}
|
}
|
||||||
else
|
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;i<pipelineInfo.pColorBlendState->attachmentCount;i++)
|
for(uint32_t i=0;i<pipelineInfo.pColorBlendState->attachmentCount;i++)
|
||||||
dos->Write(pipelineInfo.pColorBlendState->pAttachments+i,sizeof(VkPipelineColorBlendAttachmentState));
|
WRITE_AND_CHECK_SIZE(pipelineInfo.pColorBlendState->pAttachments+i,VkPipelineColorBlendAttachmentState);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,12 @@ PipelineCreater::PipelineCreater(Device *dev,const Material *material,RenderPass
|
|||||||
pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
|
pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
|
||||||
InitVertexInputState(material);
|
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();
|
InitViewportState();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user