* 管线代码整理

This commit is contained in:
2026-06-23 17:01:42 +08:00
parent a837bc291d
commit e5ab18aa61
3 changed files with 1040 additions and 966 deletions
+995 -935
View File
File diff suppressed because it is too large Load Diff
+44 -30
View File
@@ -134,7 +134,7 @@ constexpr size_t NUM_START_2D_VERTEX = 4 * 1024;
// 最大根坐标系数(2d的cbo数)
constexpr size_t NUM_MAX_ROOT_COOR = 32;
// 样本着色
// 样本着色(更高级的多重采样,基本不会使用)
constexpr bool OPEN_SAMPLE_SHADING = false;
// 线框模式(很多设备不支持)
constexpr bool OPEN_FILL_MODE_NON_SOLID = false;
@@ -850,17 +850,17 @@ public:
~VK();
private:
struct Pipeline
{
VkPipelineLayout _layout; // 管线布局
VkPipeline _pipe; // 图形管线
//struct Pipeline
//{
// VkPipelineLayout _layout; // 管线布局
// VkPipeline _pipe; // 图形管线
void Delete(VkDevice device)
{
vkDestroyPipeline(device, _pipe, nullptr);
vkDestroyPipelineLayout(device, _layout, nullptr);
}
};
// void Delete(VkDevice device)
// {
// vkDestroyPipeline(device, _pipe, nullptr);
// vkDestroyPipelineLayout(device, _layout, nullptr);
// }
//};
VkInstance _instance; // vk实例
std::vector<VkExtensionProperties> _allExtension; // 所有扩展,返回获得
@@ -922,7 +922,6 @@ private:
std::vector<VkDeviceMemory> _ubBoneMemory; //骨骼ub内存
std::vector<bool> _mapBoneUse; //骨骼ub使用表
std::vector<Primitive> _allPrimitive; //所有图元
VkSampleCountFlagBits _msaaSamples; //msaa采样数
VkImage _colorImage; //离屏图像
VkDeviceMemory _colorImageMemory; //离屏图像内存
VkImageView _colorImageView; //离屏图像视图
@@ -968,8 +967,9 @@ private:
VkRenderPass _renderPass;
VkDescriptorSetLayout _descriptorSetLayout; // 描述符布局 set0
std::vector<VkDescriptorSet> _descriptorSets; // 描述符集(ubo)
Pipeline _pipeline;
Pipeline _pipelineBone;
VkPipelineLayout _layout;
VkPipeline _pipeline;
VkPipeline _pipelineBone;
VkSampler _sampler; // 采样器
Texture _tex;
@@ -1055,12 +1055,12 @@ private:
// 创建绘图流程
void _create_render_pass();
// 创建图形管道
void _create_graphics_pipeline();
void _create_graphics_pipeline_skybox();
void _create_pipeline_layout_3d();
void _create_pipeline_layout_skybox();
//-------------------骨骼动画-----------------
void _create_descriptor_set_layout_bone();//布局
void _create_graphics_pipeline_bone();//管线
void _create_pipeline_layout_bone();//管线
void _create_uniform_bone();//统一缓冲
void _create_ibl();
@@ -1124,16 +1124,7 @@ private:
// 创建深度缓存资源
void _create_depth_resources();
// 创建msaa资源
void _create_color_resources()
{
VkFormat colorFormat = _formatSwapChainImage;
CreateImage(_extentSwapChain.width, _extentSwapChain.height, 1, _msaaSamples, colorFormat,
VK_IMAGE_TILING_OPTIMAL,
VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, _colorImage, _colorImageMemory);
_colorImageView = CreateImageView(_colorImage, colorFormat, VK_IMAGE_ASPECT_COLOR_BIT, 1);
}
void _create_color_resources();
//2d管线
void _create_2d();
void _delete_2d();
@@ -1156,13 +1147,36 @@ private:
void _create_shadow();
void _delete_shadow();
void _create_render_pass_shadow();
Pipeline _create_graphics_pipeline_shadow(std::string_view vs, std::string_view ps,
VkVertexInputBindingDescription* bind_desc,
VkVertexInputAttributeDescription* attr_desc, size_t num_attr);
VkPipelineLayout _create_pipline_layout_shadow();
VkPipeline _create_graphics_pipeline_shadow(
std::string_view vs, std::string_view ps,
VkVertexInputBindingDescription* bind_desc, VkVertexInputAttributeDescription* attr_desc,
size_t num_attr, VkPipelineLayout layout);
void _create_descriptor_set_layout_shadow();
bool _check_gfx_vertex(VertexBufferGfx& vb_old);
//------------------------------管线-------------------------------------
void _create_pipeline_all();
void _delete_pipeline_all();
void _create_pipeline_gfx();
void _create_pipeline_2d();
void _create_pipeline_3d();
void _create_pipeline_bone();
void _create_pipeline_skybox();
void _create_pipeline_shadow();
public:
// 动态参数
struct RenderParam
{
VkSampleCountFlagBits _msaaLevel;
}_param;
void GfxLock()
{