修复 crash 的问题
This commit is contained in:
@@ -26,6 +26,7 @@ TextureLoading::TextureLoading()
|
||||
zoom = -2.5f;
|
||||
rotation = { 0.0f, 15.0f, 0.0f };
|
||||
title = "Texture loading";
|
||||
this_instance = this;
|
||||
}
|
||||
|
||||
TextureLoading::~TextureLoading()
|
||||
@@ -50,6 +51,7 @@ TextureLoading::~TextureLoading()
|
||||
vertex_buffer.reset();
|
||||
index_buffer.reset();
|
||||
uniform_buffer_vs.reset();
|
||||
//stop();
|
||||
}
|
||||
|
||||
// Enable physical device features required for this example
|
||||
@@ -507,6 +509,7 @@ void TextureLoading::build_command_buffers()
|
||||
|
||||
void TextureLoading::draw()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mtx);
|
||||
ApiVulkanSample::prepare_frame();
|
||||
|
||||
// Command buffer to be submitted to the queue
|
||||
@@ -916,15 +919,51 @@ bool TextureLoading::prepare(const vkb::ApplicationOptions& options)
|
||||
setup_descriptor_set_bg();
|
||||
build_command_buffers();
|
||||
prepared = true;
|
||||
//start();
|
||||
return true;
|
||||
}
|
||||
|
||||
//void TextureLoading::updateTexture()
|
||||
//{
|
||||
// std::unique_lock<std::mutex> lock(mtx);
|
||||
// std::cout << "Working in thread: " << std::this_thread::get_id() << std::endl;
|
||||
// int width = 640;
|
||||
// int height = 480;
|
||||
// int rowStride;
|
||||
// auto testImage = generateSimpleTestImage(width, height, &rowStride);
|
||||
// size_t dataSize = testImage.size();
|
||||
// processWithVulkan(testImage.data(), width, height, rowStride, dataSize, cam_text);
|
||||
//}
|
||||
//
|
||||
//void TextureLoading::run() {
|
||||
// std::this_thread::sleep_for(std::chrono::milliseconds(5000));
|
||||
// while (running)
|
||||
// {
|
||||
// updateTexture();
|
||||
// std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//void TextureLoading::start() {
|
||||
// running = true;
|
||||
// // 启动线程执行 run 方法
|
||||
// workerThread = std::thread(&TextureLoading::run, this);
|
||||
//}
|
||||
//
|
||||
//void TextureLoading::stop() {
|
||||
// running = false;
|
||||
// if (workerThread.joinable()) {
|
||||
// workerThread.join();
|
||||
// }
|
||||
//}
|
||||
|
||||
void TextureLoading::render(float delta_time)
|
||||
{
|
||||
if (!prepared)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
draw();
|
||||
}
|
||||
|
||||
@@ -959,6 +998,7 @@ void TextureLoadProcessWithVulkan(uint8_t* data, int width, int height, int rowS
|
||||
|
||||
void TextureLoading::processWithVulkan(uint8_t* data, int width, int height, int rowStride, size_t dataSize, Texture& out_texture)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mtx);
|
||||
VkDevice& device = get_device().get_handle();
|
||||
const VkPhysicalDevice& physicalDevice = get_device().get_gpu().get_handle();
|
||||
if (out_texture.image == VK_NULL_HANDLE)
|
||||
|
||||
Reference in New Issue
Block a user