update
This commit is contained in:
parent
c652f8c86d
commit
1eee0be937
@ -4,5 +4,6 @@ namespace api {
|
||||
class Texture : public Resource<Texture>
|
||||
{
|
||||
public:
|
||||
void* mPtr;
|
||||
};
|
||||
}
|
||||
@ -17,7 +17,26 @@ namespace api {
|
||||
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
|
||||
// any transition.
|
||||
UNDEFINED,
|
||||
@ -41,22 +60,20 @@ namespace api {
|
||||
// For color attachment MSAA resolves.
|
||||
COLOR_ATTACHMENT_RESOLVE,
|
||||
};
|
||||
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.
|
||||
};
|
||||
struct TextureBarrier
|
||||
{
|
||||
//Texture* pTexture;
|
||||
ResourceState mSrcState;
|
||||
ResourceState mDstState;
|
||||
uint8_t mBeginOnly : 1;
|
||||
uint8_t mEndOnly : 1;
|
||||
uint8_t mAcquire : 1;
|
||||
uint8_t mRelease : 1;
|
||||
uint8_t mQueueType : 5;
|
||||
/// Specifiy whether following barrier targets particular subresource
|
||||
uint8_t mSubresourceBarrier : 1;
|
||||
/// Following values are ignored if mSubresourceBarrier is false
|
||||
uint8_t mMipLevel : 7;
|
||||
uint16_t mArrayLayer;
|
||||
};
|
||||
}
|
||||
@ -13,6 +13,7 @@ namespace vkn {
|
||||
using api::Shader;
|
||||
struct VulkanContext : public api::RenderContext {
|
||||
VkSemaphore surfaceSemaphore;
|
||||
VkSemaphore presentSemaphore;
|
||||
};
|
||||
class VULKAN_API VulkanAPI : public api::RenderAPI {
|
||||
private:
|
||||
|
||||
@ -57,9 +57,12 @@ namespace vkn {
|
||||
vkGetSwapchainImagesKHR(device.Ptr(), mPtr, &imageCount, nullptr);
|
||||
swapchain_images.resize(imageCount);
|
||||
vkGetSwapchainImagesKHR(device.Ptr(), mPtr, &imageCount, swapchain_images.data());
|
||||
mFences.reserve(mFrames);
|
||||
mSemaphores.reserve(mFrames + mFrames);
|
||||
for (int i = 0; i < mFrames; i++) {
|
||||
//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());
|
||||
mFences.push_back(mDevice.CreateFence(VK_FENCE_CREATE_SIGNALED_BIT));
|
||||
}
|
||||
}
|
||||
@ -68,6 +71,7 @@ namespace vkn {
|
||||
VkFence surfaceFence = mFences[ctx.frame];
|
||||
VkSemaphore surfaceSemaphore = mSemaphores[ctx.frame];
|
||||
ctx.surfaceSemaphore = surfaceSemaphore;
|
||||
ctx.presentSemaphore = mSemaphores[ctx.frame + mFrames];
|
||||
if (vkWaitForFences(mDevice.Ptr(), 1, &surfaceFence, VK_TRUE, UINT64_MAX) != VK_SUCCESS)
|
||||
throw std::runtime_error("Failed to wait for fence!");
|
||||
vkAcquireNextImageKHR(mDevice.Ptr(), mPtr, UINT64_MAX, surfaceSemaphore, VK_NULL_HANDLE, &ctx.presentFrame);
|
||||
@ -75,13 +79,11 @@ namespace vkn {
|
||||
}
|
||||
void VulkanSwapchain::Present(VulkanContext& ctx)
|
||||
{
|
||||
VkSwapchainKHR swapChains[] = { mPtr };
|
||||
VkSemaphore waitSemaphores[] = { ctx.surfaceSemaphore };
|
||||
VkPresentInfoKHR presentInfo = {};
|
||||
presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
|
||||
presentInfo.pWaitSemaphores = waitSemaphores;
|
||||
presentInfo.pWaitSemaphores = &ctx.surfaceSemaphore;
|
||||
presentInfo.waitSemaphoreCount = 1;
|
||||
presentInfo.pSwapchains = swapChains;
|
||||
presentInfo.pSwapchains = &mPtr;
|
||||
presentInfo.swapchainCount = 1;
|
||||
presentInfo.pImageIndices = &ctx.presentFrame;
|
||||
presentInfo.pResults = VK_NULL_HANDLE;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user