设备上跑通 人脸检测和 线条绘制
This commit is contained in:
@@ -626,13 +626,13 @@ uint32_t Application::findMemoryType(VkPhysicalDevice physicalDevice, uint32_t t
|
||||
throw std::runtime_error("Failed to find suitable memory type!");
|
||||
}
|
||||
|
||||
Texture Application::loadTexture(std::string path, Texture& tex)
|
||||
Texture Application::loadTexture(std::string path, Texture& tex, bool srgb)
|
||||
{
|
||||
std::vector<unsigned char> data = readFileEx(path);
|
||||
std::vector<unsigned char> image;
|
||||
unsigned w, h;
|
||||
unsigned error = lodepng::decode(image, w, h, data, LCT_RGBA, 8);
|
||||
processWithVulkan(image.data(), w, h, w * 4, image.size(), tex, true);
|
||||
processWithVulkan(image.data(), w, h, w * 4, image.size(), tex, srgb);
|
||||
return tex;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,8 @@ public:
|
||||
virtual void render(VkCommandBuffer commandBuffer);
|
||||
virtual bool isInited() { return inited; }
|
||||
|
||||
void processWithVulkan(uint8_t* data, int width, int height, int rowStride, size_t dataSize, Texture& out_texture, bool srgb);
|
||||
|
||||
protected:
|
||||
|
||||
VkPhysicalDevice physicalDevice = VK_NULL_HANDLE; // 物理设备
|
||||
@@ -69,10 +71,11 @@ protected:
|
||||
int currentFrame = 0;
|
||||
int MAX_FRAMES_IN_FLIGHT = 2;
|
||||
bool inited = false;
|
||||
|
||||
|
||||
protected:
|
||||
Texture loadTexture(std::string path, Texture& tex);
|
||||
void processWithVulkan(uint8_t* data, int width, int height, int rowStride, size_t dataSize, Texture& out_texture, bool srgb);
|
||||
Texture loadTexture(std::string path, Texture& tex, bool srgb);
|
||||
|
||||
uint32_t findMemoryType(VkPhysicalDevice physicalDevice, uint32_t typeFilter,
|
||||
VkMemoryPropertyFlags properties);
|
||||
void createTexture(VkDevice device, VkPhysicalDevice physicalDevice, int width, int height, Texture& texture, bool srgb);
|
||||
|
||||
+12
-2
@@ -24,6 +24,14 @@ void ReceiveFacePoint(float* pos, int pointCount, int width, int height)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TextureLoadProcessWithVulkan(uint8_t* data, int width, int height, int rowStride, size_t dataSize)
|
||||
{
|
||||
Texture& tex_bg = FaceApp::Get()->tex_bg;
|
||||
FaceApp::Get()->processWithVulkan(data, width, height, rowStride, dataSize, tex_bg, false);
|
||||
}
|
||||
|
||||
bool FaceApp::LoadOBJ(const std::string& filename,
|
||||
std::vector<TextureLoadingVertexStructure>& vertices,
|
||||
std::vector<uint32_t>& indices) {
|
||||
@@ -477,6 +485,8 @@ void FaceApp::setup_descriptor_set()
|
||||
|
||||
void FaceApp::render(VkCommandBuffer commandBuffer)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mtx);
|
||||
std::unique_lock<std::mutex> lock_point(mtx_point);
|
||||
//Application::render(commandBuffer);
|
||||
|
||||
vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipelineLayout_bg, 0, 1, &m_descriptor_set_bg, 0, NULL);
|
||||
@@ -539,8 +549,8 @@ void FaceApp::initVulkan()
|
||||
Application::initVulkan();
|
||||
createVmaAllocator();
|
||||
LoadOBJ("face_picture_3dmax.obj", obj_vertices, obj_indices);
|
||||
loadTexture("demo0.png", tex_demo0);
|
||||
loadTexture("out.png", tex_bg);
|
||||
loadTexture("demo0.png", tex_demo0, true);
|
||||
loadTexture("out.png", tex_bg, false);
|
||||
createVertexBuffer();
|
||||
createUniformBuffer();
|
||||
setup_descriptor_pool();
|
||||
|
||||
+4
-1
@@ -44,6 +44,9 @@ public:
|
||||
|
||||
virtual bool isInited() override { return inited && faceAppInited; }
|
||||
virtual void cleanup() override;
|
||||
|
||||
Texture tex_bg = {};
|
||||
|
||||
private:
|
||||
glm::vec3 rotation = glm::vec3();
|
||||
glm::vec3 camera_pos = glm::vec3();
|
||||
@@ -103,7 +106,7 @@ private:
|
||||
float myFloatValue = 1.5f;
|
||||
|
||||
|
||||
Texture tex_bg = {};
|
||||
|
||||
void create_pipelines_bg();
|
||||
void setup_descriptor_set_layout_bg();
|
||||
void setup_descriptor_set_bg();
|
||||
|
||||
Reference in New Issue
Block a user