Pipeline增加alpha_test/alpha_blend属性

This commit is contained in:
2019-05-23 13:29:23 +08:00
parent a988f36b92
commit 96d9132b29
3 changed files with 49 additions and 2 deletions

View File

@@ -9,12 +9,18 @@ class Pipeline
VkDevice device;
VkPipeline pipeline;
bool alpha_test;
bool alpha_blend;
public:
Pipeline(VkDevice dev,VkPipeline p){device=dev;pipeline=p;}
Pipeline(VkDevice dev,VkPipeline p,bool at,bool ab):device(dev),pipeline(p),alpha_test(at),alpha_blend(ab){}
virtual ~Pipeline();
operator VkPipeline(){return pipeline;}
const bool IsAlphaTest()const{return alpha_test;}
const bool IsAlphaBlend()const{return alpha_blend;}
};//class GraphicsPipeline
constexpr size_t MAX_SAMPLE_MASK_COUNT=(VK_SAMPLE_COUNT_64_BIT+31)/32;
@@ -54,6 +60,9 @@ class PipelineCreater
void InitDynamicState();
float alpha_test=0;
bool alpha_blend=false;
public:
PipelineCreater(Device *dev,const Material *,RenderPass *rp,const VkExtent2D &);
@@ -66,6 +75,8 @@ public:
void SetDepthRange( float min_depth,float max_depth){viewport.minDepth=min_depth;viewport.maxDepth=max_depth;}
void SetScissor( float l,float t,float w,float h){scissor.offset.x=l;scissor.offset.y=t;scissor.extent.width=w;scissor.extent.height=h;}
void SetAlphaTest( const float at) {alpha_test=at;}
void SetDepthTest( bool dt) {depthStencilState.depthTestEnable=dt;}
void SetDepthWrite( bool dw) {depthStencilState.depthWriteEnable=dw;}
@@ -115,6 +126,9 @@ public:
colorBlendAttachments.Add(*cba);
colorBlending.attachmentCount=colorBlendAttachments.GetCount();
if(cba->blendEnable)
alpha_blend=true;
}
bool SetBlend(uint index,bool blend)
@@ -125,6 +139,22 @@ public:
cba->blendEnable=blend;
if(blend)
alpha_blend=true;
else
{
cba=colorBlendAttachments.GetData();
for(uint i=0;i<colorBlendAttachments.GetCount();i++)
if(cba->blendEnable)
{
alpha_blend=true;
return(true);
}
alpha_blend=false;
}
return(true);
}