Begin improving gfx

This commit is contained in:
Bailey Harrison 2023-06-03 22:40:11 +01:00
parent 148e8d5bca
commit 64ee9120b8
2 changed files with 21 additions and 18 deletions

View File

@ -344,8 +344,12 @@ struct GFXDevice::Impl {
Swapchain swapchain{}; Swapchain swapchain{};
VkDescriptorPool descriptorPool; VkDescriptorPool descriptorPool;
std::array<std::unordered_set<gfx::UniformBuffer*>, FRAMES_IN_FLIGHT>
uniformBufferWriteQueues{}; struct WriteQueues {
std::unordered_set<gfx::UniformBuffer*> uniform_buffer_writes{};
};
std::array<WriteQueues, FRAMES_IN_FLIGHT> write_queues{};
// For one-off transfer operations not bound to a specific frame-in-flight // For one-off transfer operations not bound to a specific frame-in-flight
VkCommandPool transferCommandPool = VK_NULL_HANDLE; VkCommandPool transferCommandPool = VK_NULL_HANDLE;
@ -610,7 +614,7 @@ gfx::DrawBuffer* GFXDevice::BeginRender() {
std::vector<VkBufferMemoryBarrier2> barriers{}; std::vector<VkBufferMemoryBarrier2> barriers{};
for (gfx::UniformBuffer* uniformBuffer : for (gfx::UniformBuffer* uniformBuffer :
pimpl->uniformBufferWriteQueues[currentFrameIndex]) { pimpl->write_queues[currentFrameIndex].uniform_buffer_writes) {
VkBufferCopy copyRegion{}; VkBufferCopy copyRegion{};
copyRegion.srcOffset = 0; copyRegion.srcOffset = 0;
copyRegion.dstOffset = 0; copyRegion.dstOffset = 0;
@ -632,7 +636,7 @@ gfx::DrawBuffer* GFXDevice::BeginRender() {
barrier.offset = 0; barrier.offset = 0;
barrier.size = uniformBuffer->gpuBuffers[currentFrameIndex].size; barrier.size = uniformBuffer->gpuBuffers[currentFrameIndex].size;
} }
pimpl->uniformBufferWriteQueues[currentFrameIndex].clear(); pimpl->write_queues[currentFrameIndex].uniform_buffer_writes.clear();
VkDependencyInfo dependencyInfo{}; VkDependencyInfo dependencyInfo{};
dependencyInfo.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO; dependencyInfo.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO;
@ -1291,7 +1295,7 @@ void GFXDevice::WriteUniformBuffer(gfx::UniformBuffer* buffer, uint64_t offset,
/* queue the writes to each gpu buffer */ /* queue the writes to each gpu buffer */
// This is required as buffers cannot be updated if they are currently in use // This is required as buffers cannot be updated if they are currently in use
for (uint32_t i = 0; i < FRAMES_IN_FLIGHT; i++) { for (uint32_t i = 0; i < FRAMES_IN_FLIGHT; i++) {
pimpl->uniformBufferWriteQueues[i].insert(buffer); pimpl->write_queues[i].uniform_buffer_writes.insert(buffer);
} }
} }

View File

@ -189,20 +189,19 @@ void PlayGame(GameSettings settings) {
static float time_elapsed; static float time_elapsed;
time_elapsed += ts; time_elapsed += ts;
if (time_elapsed >= 1.0f) { if (time_elapsed >= 1.0f) {
time_elapsed = 0; time_elapsed = 0.0f;
int fpsWidth, fpsHeight; //LOG_INFO("Creating new bitmap...");
LOG_INFO("Creating new bitmap..."); //auto fpsBitmap =
/*auto fpsBitmap = // app.GetResource<engine::resources::Font>("builtin.mono")
app.GetResource<engine::resources::Font>("builtin.mono") // ->GetTextBitmap(std::to_string(ts), 768.0f, fpsWidth,
->GetTextBitmap(std::to_string(ts), 768.0f, fpsWidth, // fpsHeight);
fpsHeight);*/ //LOG_INFO("Bitmap created! Loading into new texture...");
LOG_INFO("Bitmap created! Loading into new texture..."); //textbox_renderable->material->texture_ =
/*textbox_renderable->material->texture_ = // std::make_unique<engine::resources::Texture>(
std::make_unique<engine::resources::Texture>( // &app.render_data_, fpsBitmap->data(), fpsWidth, fpsHeight,
&app.render_data_, fpsBitmap->data(), fpsWidth, fpsHeight, // engine::resources::Texture::Filtering::kBilinear);
engine::resources::Texture::Filtering::kBilinear);*/ //LOG_INFO("Texture created!");
LOG_INFO("Texture created!");
} }
}; };
} }