update
This commit is contained in:
parent
c652f8c86d
commit
1eee0be937
@ -4,5 +4,6 @@ namespace api {
|
|||||||
class Texture : public Resource<Texture>
|
class Texture : public Resource<Texture>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
void* mPtr;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -17,7 +17,26 @@ namespace api {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
enum class RenderLayout : uint8_t {
|
enum class TargetBufferFlags : uint32_t {
|
||||||
|
NONE = 0x0u, //!< No buffer selected.
|
||||||
|
COLOR0 = 0x00000001u, //!< Color buffer selected.
|
||||||
|
COLOR1 = 0x00000002u, //!< Color buffer selected.
|
||||||
|
COLOR2 = 0x00000004u, //!< Color buffer selected.
|
||||||
|
COLOR3 = 0x00000008u, //!< Color buffer selected.
|
||||||
|
COLOR4 = 0x00000010u, //!< Color buffer selected.
|
||||||
|
COLOR5 = 0x00000020u, //!< Color buffer selected.
|
||||||
|
COLOR6 = 0x00000040u, //!< Color buffer selected.
|
||||||
|
COLOR7 = 0x00000080u, //!< Color buffer selected.
|
||||||
|
|
||||||
|
COLOR = COLOR0, //!< \deprecated
|
||||||
|
COLOR_ALL = COLOR0 | COLOR1 | COLOR2 | COLOR3 | COLOR4 | COLOR5 | COLOR6 | COLOR7,
|
||||||
|
DEPTH = 0x10000000u, //!< Depth buffer selected.
|
||||||
|
STENCIL = 0x20000000u, //!< Stencil buffer selected.
|
||||||
|
DEPTH_AND_STENCIL = DEPTH | STENCIL, //!< depth and stencil buffer selected.
|
||||||
|
ALL = COLOR_ALL | DEPTH | STENCIL //!< Color, depth and stencil buffer selected.
|
||||||
|
};
|
||||||
|
enum class ResourceState
|
||||||
|
{
|
||||||
// The initial layout after the creation of the VkImage. We use this to denote the state before
|
// The initial layout after the creation of the VkImage. We use this to denote the state before
|
||||||
// any transition.
|
// any transition.
|
||||||
UNDEFINED,
|
UNDEFINED,
|
||||||
@ -41,22 +60,20 @@ namespace api {
|
|||||||
// For color attachment MSAA resolves.
|
// For color attachment MSAA resolves.
|
||||||
COLOR_ATTACHMENT_RESOLVE,
|
COLOR_ATTACHMENT_RESOLVE,
|
||||||
};
|
};
|
||||||
enum class TargetBufferFlags : uint32_t {
|
struct TextureBarrier
|
||||||
NONE = 0x0u, //!< No buffer selected.
|
{
|
||||||
COLOR0 = 0x00000001u, //!< Color buffer selected.
|
//Texture* pTexture;
|
||||||
COLOR1 = 0x00000002u, //!< Color buffer selected.
|
ResourceState mSrcState;
|
||||||
COLOR2 = 0x00000004u, //!< Color buffer selected.
|
ResourceState mDstState;
|
||||||
COLOR3 = 0x00000008u, //!< Color buffer selected.
|
uint8_t mBeginOnly : 1;
|
||||||
COLOR4 = 0x00000010u, //!< Color buffer selected.
|
uint8_t mEndOnly : 1;
|
||||||
COLOR5 = 0x00000020u, //!< Color buffer selected.
|
uint8_t mAcquire : 1;
|
||||||
COLOR6 = 0x00000040u, //!< Color buffer selected.
|
uint8_t mRelease : 1;
|
||||||
COLOR7 = 0x00000080u, //!< Color buffer selected.
|
uint8_t mQueueType : 5;
|
||||||
|
/// Specifiy whether following barrier targets particular subresource
|
||||||
COLOR = COLOR0, //!< \deprecated
|
uint8_t mSubresourceBarrier : 1;
|
||||||
COLOR_ALL = COLOR0 | COLOR1 | COLOR2 | COLOR3 | COLOR4 | COLOR5 | COLOR6 | COLOR7,
|
/// Following values are ignored if mSubresourceBarrier is false
|
||||||
DEPTH = 0x10000000u, //!< Depth buffer selected.
|
uint8_t mMipLevel : 7;
|
||||||
STENCIL = 0x20000000u, //!< Stencil buffer selected.
|
uint16_t mArrayLayer;
|
||||||
DEPTH_AND_STENCIL = DEPTH | STENCIL, //!< depth and stencil buffer selected.
|
};
|
||||||
ALL = COLOR_ALL | DEPTH | STENCIL //!< Color, depth and stencil buffer selected.
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
@ -13,6 +13,7 @@ namespace vkn {
|
|||||||
using api::Shader;
|
using api::Shader;
|
||||||
struct VulkanContext : public api::RenderContext {
|
struct VulkanContext : public api::RenderContext {
|
||||||
VkSemaphore surfaceSemaphore;
|
VkSemaphore surfaceSemaphore;
|
||||||
|
VkSemaphore presentSemaphore;
|
||||||
};
|
};
|
||||||
class VULKAN_API VulkanAPI : public api::RenderAPI {
|
class VULKAN_API VulkanAPI : public api::RenderAPI {
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -57,9 +57,12 @@ namespace vkn {
|
|||||||
vkGetSwapchainImagesKHR(device.Ptr(), mPtr, &imageCount, nullptr);
|
vkGetSwapchainImagesKHR(device.Ptr(), mPtr, &imageCount, nullptr);
|
||||||
swapchain_images.resize(imageCount);
|
swapchain_images.resize(imageCount);
|
||||||
vkGetSwapchainImagesKHR(device.Ptr(), mPtr, &imageCount, swapchain_images.data());
|
vkGetSwapchainImagesKHR(device.Ptr(), mPtr, &imageCount, swapchain_images.data());
|
||||||
|
mFences.reserve(mFrames);
|
||||||
|
mSemaphores.reserve(mFrames + mFrames);
|
||||||
for (int i = 0; i < mFrames; i++) {
|
for (int i = 0; i < mFrames; i++) {
|
||||||
//mSurfaces.push_back(new Image(Creator.device, "swapchain" + to_string(i), swapchain_images[i], args));
|
//mSurfaces.push_back(new Image(Creator.device, "swapchain" + to_string(i), swapchain_images[i], args));
|
||||||
mSemaphores.push_back(mDevice.CreateSemaphore());
|
mSemaphores.push_back(mDevice.CreateSemaphore());
|
||||||
|
mSemaphores.push_back(mDevice.CreateSemaphore());
|
||||||
mFences.push_back(mDevice.CreateFence(VK_FENCE_CREATE_SIGNALED_BIT));
|
mFences.push_back(mDevice.CreateFence(VK_FENCE_CREATE_SIGNALED_BIT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,6 +71,7 @@ namespace vkn {
|
|||||||
VkFence surfaceFence = mFences[ctx.frame];
|
VkFence surfaceFence = mFences[ctx.frame];
|
||||||
VkSemaphore surfaceSemaphore = mSemaphores[ctx.frame];
|
VkSemaphore surfaceSemaphore = mSemaphores[ctx.frame];
|
||||||
ctx.surfaceSemaphore = surfaceSemaphore;
|
ctx.surfaceSemaphore = surfaceSemaphore;
|
||||||
|
ctx.presentSemaphore = mSemaphores[ctx.frame + mFrames];
|
||||||
if (vkWaitForFences(mDevice.Ptr(), 1, &surfaceFence, VK_TRUE, UINT64_MAX) != VK_SUCCESS)
|
if (vkWaitForFences(mDevice.Ptr(), 1, &surfaceFence, VK_TRUE, UINT64_MAX) != VK_SUCCESS)
|
||||||
throw std::runtime_error("Failed to wait for fence!");
|
throw std::runtime_error("Failed to wait for fence!");
|
||||||
vkAcquireNextImageKHR(mDevice.Ptr(), mPtr, UINT64_MAX, surfaceSemaphore, VK_NULL_HANDLE, &ctx.presentFrame);
|
vkAcquireNextImageKHR(mDevice.Ptr(), mPtr, UINT64_MAX, surfaceSemaphore, VK_NULL_HANDLE, &ctx.presentFrame);
|
||||||
@ -75,13 +79,11 @@ namespace vkn {
|
|||||||
}
|
}
|
||||||
void VulkanSwapchain::Present(VulkanContext& ctx)
|
void VulkanSwapchain::Present(VulkanContext& ctx)
|
||||||
{
|
{
|
||||||
VkSwapchainKHR swapChains[] = { mPtr };
|
|
||||||
VkSemaphore waitSemaphores[] = { ctx.surfaceSemaphore };
|
|
||||||
VkPresentInfoKHR presentInfo = {};
|
VkPresentInfoKHR presentInfo = {};
|
||||||
presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
|
presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
|
||||||
presentInfo.pWaitSemaphores = waitSemaphores;
|
presentInfo.pWaitSemaphores = &ctx.surfaceSemaphore;
|
||||||
presentInfo.waitSemaphoreCount = 1;
|
presentInfo.waitSemaphoreCount = 1;
|
||||||
presentInfo.pSwapchains = swapChains;
|
presentInfo.pSwapchains = &mPtr;
|
||||||
presentInfo.swapchainCount = 1;
|
presentInfo.swapchainCount = 1;
|
||||||
presentInfo.pImageIndices = &ctx.presentFrame;
|
presentInfo.pImageIndices = &ctx.presentFrame;
|
||||||
presentInfo.pResults = VK_NULL_HANDLE;
|
presentInfo.pResults = VK_NULL_HANDLE;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user