mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 23:25:40 +12:00
Initialize command buffer allocationFix SDL_Vulkan_GetDrawableSize
call
This commit is contained in:
parent
fa804ae4c7
commit
90a4c9cf8d
2 changed files with 28 additions and 3 deletions
|
@ -30,6 +30,9 @@ class RendererVK final : public Renderer {
|
||||||
std::vector<vk::Image> swapchainImages = {};
|
std::vector<vk::Image> swapchainImages = {};
|
||||||
std::vector<vk::UniqueImageView> swapchainImageViews = {};
|
std::vector<vk::UniqueImageView> swapchainImageViews = {};
|
||||||
|
|
||||||
|
vk::UniqueCommandPool commandPool = {};
|
||||||
|
vk::UniqueCommandBuffer presentCommandBuffer = {};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RendererVK(GPU& gpu, const std::array<u32, regNum>& internalRegs);
|
RendererVK(GPU& gpu, const std::array<u32, regNum>& internalRegs);
|
||||||
~RendererVK() override;
|
~RendererVK() override;
|
||||||
|
|
|
@ -29,7 +29,7 @@ RendererVK::~RendererVK() {}
|
||||||
void RendererVK::reset() {}
|
void RendererVK::reset() {}
|
||||||
|
|
||||||
void RendererVK::display() {
|
void RendererVK::display() {
|
||||||
u32 swapchainImageIndex;
|
u32 swapchainImageIndex = ~0u;
|
||||||
if (const auto acquireResult = device->acquireNextImageKHR(swapchain.get(), ~0ULL, presetWaitSemaphore.get());
|
if (const auto acquireResult = device->acquireNextImageKHR(swapchain.get(), ~0ULL, presetWaitSemaphore.get());
|
||||||
acquireResult.result == vk::Result::eSuccess) {
|
acquireResult.result == vk::Result::eSuccess) {
|
||||||
swapchainImageIndex = acquireResult.value;
|
swapchainImageIndex = acquireResult.value;
|
||||||
|
@ -53,7 +53,7 @@ void RendererVK::display() {
|
||||||
static const vk::PipelineStageFlags waitStageMask = vk::PipelineStageFlagBits::eAllCommands;
|
static const vk::PipelineStageFlags waitStageMask = vk::PipelineStageFlagBits::eAllCommands;
|
||||||
submitInfo.setWaitDstStageMask(waitStageMask);
|
submitInfo.setWaitDstStageMask(waitStageMask);
|
||||||
|
|
||||||
submitInfo.setCommandBuffers({});
|
submitInfo.setCommandBuffers(presentCommandBuffer.get());
|
||||||
submitInfo.setSignalSemaphores(renderDoneSemaphore.get());
|
submitInfo.setSignalSemaphores(renderDoneSemaphore.get());
|
||||||
|
|
||||||
if (const vk::Result submitResult = presentQueue.submit({submitInfo}); submitResult != vk::Result::eSuccess) {
|
if (const vk::Result submitResult = presentQueue.submit({submitInfo}); submitResult != vk::Result::eSuccess) {
|
||||||
|
@ -284,7 +284,7 @@ void RendererVK::initGraphicsContext(SDL_Window* window) {
|
||||||
vk::Extent2D swapchainExtent;
|
vk::Extent2D swapchainExtent;
|
||||||
{
|
{
|
||||||
int windowWidth, windowHeight;
|
int windowWidth, windowHeight;
|
||||||
SDL_Vulkan_GetDrawableSize(window, &windowHeight, &windowWidth);
|
SDL_Vulkan_GetDrawableSize(window, &windowWidth, &windowHeight);
|
||||||
swapchainExtent.width = windowWidth;
|
swapchainExtent.width = windowWidth;
|
||||||
swapchainExtent.height = windowHeight;
|
swapchainExtent.height = windowHeight;
|
||||||
}
|
}
|
||||||
|
@ -415,6 +415,28 @@ void RendererVK::initGraphicsContext(SDL_Window* window) {
|
||||||
} else {
|
} else {
|
||||||
Helpers::panic("Error creating acquiring swapchain images: %s\n", vk::to_string(getResult.result).c_str());
|
Helpers::panic("Error creating acquiring swapchain images: %s\n", vk::to_string(getResult.result).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Command pool
|
||||||
|
vk::CommandPoolCreateInfo commandPoolInfo = {};
|
||||||
|
commandPoolInfo.flags = vk::CommandPoolCreateFlagBits::eResetCommandBuffer;
|
||||||
|
|
||||||
|
if (auto createResult = device->createCommandPoolUnique(commandPoolInfo); createResult.result == vk::Result::eSuccess) {
|
||||||
|
commandPool = std::move(createResult.value);
|
||||||
|
} else {
|
||||||
|
Helpers::panic("Error creating command pool: %s\n", vk::to_string(createResult.result).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Command buffer(s)
|
||||||
|
vk::CommandBufferAllocateInfo commandBuffersInfo = {};
|
||||||
|
commandBuffersInfo.commandPool = commandPool.get();
|
||||||
|
commandBuffersInfo.level = vk::CommandBufferLevel::ePrimary;
|
||||||
|
commandBuffersInfo.commandBufferCount = 1;
|
||||||
|
|
||||||
|
if (auto allocateResult = device->allocateCommandBuffersUnique(commandBuffersInfo); allocateResult.result == vk::Result::eSuccess) {
|
||||||
|
presentCommandBuffer = std::move(allocateResult.value[0]);
|
||||||
|
} else {
|
||||||
|
Helpers::panic("Error allocating command buffer: %s\n", vk::to_string(allocateResult.result).c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererVK::clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) {}
|
void RendererVK::clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) {}
|
||||||
|
|
Loading…
Add table
Reference in a new issue