完成背景的推送。
This commit is contained in:
@@ -562,6 +562,19 @@ void TextureLoading::build_command_buffers()
|
||||
|
||||
vkCmdBindDescriptorSets(draw_cmd_buffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout_bg, 0, 1, &descriptor_set_bg, 0, NULL);
|
||||
vkCmdBindPipeline(draw_cmd_buffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.background);
|
||||
|
||||
// 在命令缓冲区记录时
|
||||
float myFloatValue = 1.5f; // 你的 float 值
|
||||
|
||||
vkCmdPushConstants(
|
||||
draw_cmd_buffers[i], // 命令缓冲区
|
||||
pipeline_layout_bg, // 管线布局
|
||||
VK_SHADER_STAGE_VERTEX_BIT, //
|
||||
0, // 偏移量(字节)
|
||||
sizeof(float), // 数据大小(字节)
|
||||
&myFloatValue // 数据指针
|
||||
);
|
||||
|
||||
vkCmdDraw(draw_cmd_buffers[i], 6, 1, 0, 0);
|
||||
|
||||
//vkCmdBindDescriptorSets(draw_cmd_buffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 1, &descriptor_set, 0, NULL);
|
||||
@@ -759,6 +772,14 @@ void TextureLoading::setup_descriptor_set_layout_bg()
|
||||
&descriptor_set_layout_bg,
|
||||
1);
|
||||
|
||||
VkPushConstantRange pushConstantRange{};
|
||||
pushConstantRange.stageFlags = VK_SHADER_STAGE_VERTEX_BIT; // 只在片段着色器中使用
|
||||
pushConstantRange.offset = 0;
|
||||
pushConstantRange.size = sizeof(float); // 或者 sizeof(PushConstants)
|
||||
|
||||
pipeline_layout_create_info.pushConstantRangeCount = 1;
|
||||
pipeline_layout_create_info.pPushConstantRanges = &pushConstantRange;
|
||||
|
||||
VK_CHECK(vkCreatePipelineLayout(get_device().get_handle(), &pipeline_layout_create_info, nullptr, &pipeline_layout_bg));
|
||||
}
|
||||
|
||||
@@ -1427,18 +1448,21 @@ bool TextureLoading::prepare(const vkb::ApplicationOptions& options)
|
||||
size_t dataSize = testImage.size();
|
||||
processWithVulkan(testImage.data(), width, height, rowStride, dataSize, texture_point);
|
||||
|
||||
#ifndef _WIN32
|
||||
width = 640;
|
||||
height = 480;
|
||||
rowStride = width * 4;
|
||||
auto arrowImage = generateSimpleTestImage(width, height, 80);
|
||||
dataSize = arrowImage.size();
|
||||
processWithVulkan(arrowImage.data(), width, height, rowStride, dataSize, cam_text);
|
||||
#else
|
||||
|
||||
//const char* filename = "face.png";
|
||||
//std::vector<unsigned char> image;
|
||||
//unsigned w, h;
|
||||
//unsigned error = lodepng::decode(image, w, h, filename, LCT_RGBA, 8);
|
||||
//processWithVulkan(image.data(), w, h, w*4, image.size(), cam_text);
|
||||
const char* filename = "face.png";
|
||||
std::vector<unsigned char> image;
|
||||
unsigned w, h;
|
||||
unsigned error = lodepng::decode(image, w, h, filename, LCT_RGBA, 8);
|
||||
processWithVulkan(image.data(), w, h, w*4, image.size(), cam_text);
|
||||
#endif
|
||||
|
||||
width = 256;
|
||||
height = 256;
|
||||
|
||||
Reference in New Issue
Block a user