Skip to content

Commit 99d4db6

Browse files
Better image upload batching (4s->1s in Bistro), fixed Tracy mismatched new/delete, and added more Tracy instrumentation.
1 parent 9d25f1c commit 99d4db6

File tree

3 files changed

+244
-74
lines changed

3 files changed

+244
-74
lines changed

src/Application.cpp

Lines changed: 56 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,12 @@ Application::Application(const CreateInfo& createInfo)
231231
: presentMode(createInfo.presentMode)
232232
{
233233
ZoneScoped;
234-
// Initialiize GLFW
235-
if (!glfwInit())
236234
{
237-
throw std::runtime_error("Failed to initialize GLFW");
235+
ZoneScopedN("Initialize GLFW");
236+
if (!glfwInit())
237+
{
238+
throw std::runtime_error("Failed to initialize GLFW");
239+
}
238240
}
239241

240242
destroyList_.Push([] { glfwTerminate(); });
@@ -251,10 +253,13 @@ Application::Application(const CreateInfo& createInfo)
251253
throw std::runtime_error("No monitor detected");
252254
}
253255
const GLFWvidmode* videoMode = glfwGetVideoMode(monitor);
254-
window = glfwCreateWindow(static_cast<int>(videoMode->width * .75), static_cast<int>(videoMode->height * .75), createInfo.name.data(), nullptr, nullptr);
255-
if (!window)
256256
{
257-
throw std::runtime_error("Failed to create window");
257+
ZoneScopedN("Create Window");
258+
window = glfwCreateWindow(static_cast<int>(videoMode->width * .75), static_cast<int>(videoMode->height * .75), createInfo.name.data(), nullptr, nullptr);
259+
if (!window)
260+
{
261+
throw std::runtime_error("Failed to create window");
262+
}
258263
}
259264

260265
int xSize{};
@@ -281,51 +286,67 @@ Application::Application(const CreateInfo& createInfo)
281286

282287
// Initialize Vulkan
283288
// instance
284-
instance_ = vkb::InstanceBuilder()
285-
.set_app_name("Frogrenderer")
286-
.require_api_version(1, 3, 0)
287-
.set_debug_callback(vulkan_debug_callback)
288-
.enable_extension(VK_EXT_DEBUG_UTILS_EXTENSION_NAME)
289-
.build()
290-
.value();
291-
292-
if (volkInitialize() != VK_SUCCESS)
293289
{
294-
throw std::runtime_error("rip");
290+
ZoneScopedN("Create Vulkan Instance");
291+
instance_ = vkb::InstanceBuilder()
292+
.set_app_name("Frogrenderer")
293+
.require_api_version(1, 3, 0)
294+
.set_debug_callback(vulkan_debug_callback)
295+
.enable_extension(VK_EXT_DEBUG_UTILS_EXTENSION_NAME)
296+
.build()
297+
.value();
295298
}
296299

297-
destroyList_.Push([] { volkFinalize(); });
300+
{
301+
ZoneScopedN("Initialize Volk");
302+
if (volkInitialize() != VK_SUCCESS)
303+
{
304+
throw std::runtime_error("rip");
305+
}
306+
307+
destroyList_.Push([] { volkFinalize(); });
298308

299-
volkLoadInstance(instance_);
309+
volkLoadInstance(instance_);
310+
}
300311

301312
// surface
302313
VkSurfaceKHR surface;
303-
if (auto err = glfwCreateWindowSurface(instance_, window, nullptr, &surface); err != VK_SUCCESS)
304314
{
305-
const char* error_msg;
306-
if (int ret = glfwGetError(&error_msg))
315+
ZoneScopedN("Create Window Surface");
316+
if (auto err = glfwCreateWindowSurface(instance_, window, nullptr, &surface); err != VK_SUCCESS)
307317
{
308-
std::cout << ret << " ";
309-
if (error_msg != nullptr)
310-
std::cout << error_msg;
311-
std::cout << "\n";
318+
const char* error_msg;
319+
if (int ret = glfwGetError(&error_msg))
320+
{
321+
std::cout << ret << " ";
322+
if (error_msg != nullptr)
323+
std::cout << error_msg;
324+
std::cout << "\n";
325+
}
326+
throw std::runtime_error("rip");
312327
}
313-
throw std::runtime_error("rip");
314328
}
329+
315330
destroyList_.Push([this] { vkDestroySurfaceKHR(instance_, surface_, nullptr); });
316331

317332
// device
318-
device_.emplace(instance_, surface);
333+
{
334+
ZoneScopedN("Create Device");
335+
device_.emplace(instance_, surface);
336+
}
319337

320338
// swapchain
321-
swapchain_ = MakeVkbSwapchain(device_->device_,
322-
windowFramebufferWidth,
323-
windowFramebufferHeight,
324-
presentMode,
325-
device_->frameOverlap,
326-
VK_NULL_HANDLE,
327-
swapchainSrgbFormat,
328-
swapchainUnormFormat);
339+
{
340+
ZoneScopedN("Create Swapchain");
341+
swapchain_ = MakeVkbSwapchain(device_->device_,
342+
windowFramebufferWidth,
343+
windowFramebufferHeight,
344+
presentMode,
345+
device_->frameOverlap,
346+
VK_NULL_HANDLE,
347+
swapchainSrgbFormat,
348+
swapchainUnormFormat);
349+
}
329350
swapchainImages_ = swapchain_.get_images().value();
330351
swapchainImageViewsSrgb_ = MakeSwapchainImageViews(device_->device_, swapchainImages_, swapchainSrgbFormat);
331352
swapchainImageViewsUnorm_ = MakeSwapchainImageViews(device_->device_, swapchainImages_, swapchainUnormFormat);

src/Fvog/Texture2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace Fvog
1818
class Device;
1919
class TextureView;
2020
class Texture;
21+
class Buffer;
2122

2223
namespace detail
2324
{

0 commit comments

Comments
 (0)