CommandBuffer增加PushConstants(const PushConstant128/256)函数定义
This commit is contained in:
parent
32bc14725d
commit
9af0f095d8
@ -63,20 +63,6 @@ enum class ShaderType
|
|||||||
Compute =VK_SHADER_STAGE_COMPUTE_BIT
|
Compute =VK_SHADER_STAGE_COMPUTE_BIT
|
||||||
};//
|
};//
|
||||||
|
|
||||||
struct PushConstant256
|
|
||||||
{
|
|
||||||
Matrix4f projection;
|
|
||||||
Matrix4f modelview;
|
|
||||||
Matrix4f mvp;
|
|
||||||
Matrix3f normal;
|
|
||||||
};//
|
|
||||||
|
|
||||||
struct PushConstant128
|
|
||||||
{
|
|
||||||
Matrix4f projection;
|
|
||||||
Matrix4f modelview;
|
|
||||||
};//
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
bool CheckStrideBytesByFormat(); ///<检验所有数据类型长度数组是否符合规则
|
bool CheckStrideBytesByFormat(); ///<检验所有数据类型长度数组是否符合规则
|
||||||
#endif//_DEBUG
|
#endif//_DEBUG
|
||||||
|
@ -5,6 +5,23 @@
|
|||||||
#include<hgl/graph/vulkan/VKPipeline.h>
|
#include<hgl/graph/vulkan/VKPipeline.h>
|
||||||
#include<hgl/graph/vulkan/VKDescriptorSets.h>
|
#include<hgl/graph/vulkan/VKDescriptorSets.h>
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
|
//push constant 一般只有128/256字节,仅能存在矩阵。
|
||||||
|
//所以我们将每个对象的独立变换矩阵存在push constant中
|
||||||
|
|
||||||
|
struct PushConstant256
|
||||||
|
{
|
||||||
|
Matrix4f projection;
|
||||||
|
Matrix4f modelview;
|
||||||
|
Matrix4f mvp;
|
||||||
|
Matrix3f normal;
|
||||||
|
};//
|
||||||
|
|
||||||
|
struct PushConstant128
|
||||||
|
{
|
||||||
|
Matrix4f projection;
|
||||||
|
Matrix4f modelview;
|
||||||
|
};//
|
||||||
|
|
||||||
class CommandBuffer
|
class CommandBuffer
|
||||||
{
|
{
|
||||||
VkDevice device;
|
VkDevice device;
|
||||||
@ -95,6 +112,9 @@ public:
|
|||||||
vkCmdPushConstants(cmd_buf,pipeline_layout,(VkShaderStageFlagBits)shader_type,offset,size,pValues);
|
vkCmdPushConstants(cmd_buf,pipeline_layout,(VkShaderStageFlagBits)shader_type,offset,size,pValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PushConstants(const PushConstant256 *pc){vkCmdPushConstants(cmd_buf,pipeline_layout,VK_SHADER_STAGE_VERTEX_BIT,0,sizeof(PushConstant256),pc);}
|
||||||
|
void PushConstants(const PushConstant128 *pc){vkCmdPushConstants(cmd_buf,pipeline_layout,VK_SHADER_STAGE_VERTEX_BIT,0,sizeof(PushConstant128),pc);}
|
||||||
|
|
||||||
bool Bind(Renderable *);
|
bool Bind(Renderable *);
|
||||||
|
|
||||||
void SetViewport (uint32_t first,uint32_t count,const VkViewport *vp) {vkCmdSetViewport(cmd_buf,first,count,vp);}
|
void SetViewport (uint32_t first,uint32_t count,const VkViewport *vp) {vkCmdSetViewport(cmd_buf,first,count,vp);}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user