增加Pipeline多边形设置和视口设置
This commit is contained in:
parent
330a4417d6
commit
ef86341146
@ -3,6 +3,39 @@
|
||||
#include"VKVertexInput.h"
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
Pipeline::~Pipeline()
|
||||
{
|
||||
vkDestroyPipeline(device,pipeline,nullptr);
|
||||
}
|
||||
|
||||
PipelineCreater::PipelineCreater(VkDevice dev,uint w,uint h)
|
||||
{
|
||||
device=dev;
|
||||
width=w;
|
||||
height=h;
|
||||
hgl_zero(pipelineInfo);
|
||||
pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
|
||||
|
||||
viewport.x = 0.0f;
|
||||
viewport.y = 0.0f;
|
||||
viewport.width = width;
|
||||
viewport.height = height;
|
||||
viewport.minDepth = 0.0f;
|
||||
viewport.maxDepth = 1.0f;
|
||||
|
||||
scissor.offset = {0, 0};
|
||||
scissor.extent.width=width;
|
||||
scissor.extent.height=height;
|
||||
|
||||
viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
|
||||
viewportState.viewportCount = 1;
|
||||
viewportState.pViewports = &viewport;
|
||||
viewportState.scissorCount = 1;
|
||||
viewportState.pScissors = &scissor;
|
||||
|
||||
pipelineInfo.pViewportState = &viewportState;
|
||||
}
|
||||
|
||||
bool PipelineCreater::Set(const Shader *s)
|
||||
{
|
||||
if(!s)return(false);
|
||||
@ -20,6 +53,7 @@ bool PipelineCreater::Set(const Shader *s)
|
||||
bool PipelineCreater::Set(const VertexInput *vi)
|
||||
{
|
||||
if(!vi)return(false);
|
||||
if(vi->GetCount()<=0)return(false);
|
||||
|
||||
vertex_input=vi;
|
||||
|
||||
@ -29,10 +63,20 @@ bool PipelineCreater::Set(const VertexInput *vi)
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool PipelineCreater::Set(const VkPrimitiveTopology topology,bool restart)
|
||||
{
|
||||
if(topology<VK_PRIMITIVE_TOPOLOGY_BEGIN_RANGE||topology>VK_PRIMITIVE_TOPOLOGY_END_RANGE)return(false);
|
||||
|
||||
inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
|
||||
inputAssembly.topology = topology;
|
||||
inputAssembly.primitiveRestartEnable = restart;
|
||||
|
||||
pipelineInfo.pInputAssemblyState = &inputAssembly;
|
||||
return(true);
|
||||
}
|
||||
|
||||
Pipeline *PipelineCreater::Create()
|
||||
{
|
||||
//pipelineInfo.pInputAssemblyState = &inputAssembly;
|
||||
//pipelineInfo.pViewportState = &viewportState;
|
||||
//pipelineInfo.pRasterizationState = &rasterizer;
|
||||
//pipelineInfo.pMultisampleState = &multisampling;
|
||||
//pipelineInfo.pColorBlendState = &colorBlending;
|
||||
@ -41,12 +85,11 @@ Pipeline *PipelineCreater::Create()
|
||||
//pipelineInfo.subpass = 0;
|
||||
//pipelineInfo.basePipelineHandle = VK_NULL_HANDLE;
|
||||
|
||||
//VkPipeline graphicsPipeline;
|
||||
|
||||
//if (vkCreateGraphicsPipelines(device, VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &graphicsPipeline) != VK_SUCCESS) {
|
||||
// throw std::runtime_error("failed to create graphics pipeline!");
|
||||
//}
|
||||
VkPipeline graphicsPipeline;
|
||||
|
||||
if (vkCreateGraphicsPipelines(device, VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &graphicsPipeline) != VK_SUCCESS)
|
||||
return(nullptr);
|
||||
|
||||
return(new Pipeline(device,graphicsPipeline));
|
||||
}
|
||||
VK_NAMESPACE_END
|
||||
|
@ -6,11 +6,12 @@
|
||||
VK_NAMESPACE_BEGIN
|
||||
class Pipeline
|
||||
{
|
||||
VkDevice device;
|
||||
VkPipeline pipeline;
|
||||
|
||||
public:
|
||||
|
||||
Pipeline(VkPipeline p){pipeline=p;}
|
||||
Pipeline(VkDevice dev,VkPipeline p){device=dev;pipeline=p;}
|
||||
virtual ~Pipeline();
|
||||
};//class GraphicsPipeline
|
||||
|
||||
@ -19,9 +20,16 @@ class VertexInput;
|
||||
|
||||
class PipelineCreater
|
||||
{
|
||||
VkDevice device;
|
||||
uint width,height;
|
||||
VkGraphicsPipelineCreateInfo pipelineInfo;
|
||||
|
||||
VkPipelineVertexInputStateCreateInfo vis_create_info;
|
||||
VkPipelineInputAssemblyStateCreateInfo inputAssembly;
|
||||
|
||||
VkViewport viewport;
|
||||
VkRect2D scissor;
|
||||
VkPipelineViewportStateCreateInfo viewportState;
|
||||
|
||||
private:
|
||||
|
||||
@ -30,14 +38,12 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
PipelineCreater()
|
||||
{
|
||||
pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
|
||||
}
|
||||
PipelineCreater(VkDevice dev,uint w,uint h);
|
||||
~PipelineCreater();
|
||||
|
||||
bool Set(const Shader *);
|
||||
bool Set(const VertexInput *);
|
||||
bool Set(const VkPrimitiveTopology,bool=false);
|
||||
|
||||
Pipeline *Create();
|
||||
};//class PipelineCreater
|
||||
|
@ -43,6 +43,7 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
const uint GetCount()const{return buf_list.GetCount();}
|
||||
const List<VkBuffer> &GetBufferList()const{return buf_list;}
|
||||
|
||||
const VkPipelineVertexInputStateCreateInfo GetPipelineVertexInputStateCreateInfo()const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user