VulkanBinding: make a dummy Vulkan swapchain impl

This commit is contained in:
Corentin Wallez 2017-11-22 17:27:17 -05:00 committed by Corentin Wallez
parent eee5171c39
commit bdde209ed9
2 changed files with 52 additions and 1 deletions

View File

@ -66,4 +66,9 @@ typedef struct {
} nxtWSIContextGL; } nxtWSIContextGL;
#endif #endif
#ifdef NXT_ENABLE_BACKEND_VULKAN
typedef struct {
} nxtWSIContextVulkan;
#endif
#endif // NXT_WSI_H #endif // NXT_WSI_H

View File

@ -14,6 +14,9 @@
#include "utils/BackendBinding.h" #include "utils/BackendBinding.h"
#include "nxt/nxt_wsi.h"
#include "utils/SwapChainImpl.h"
namespace backend { namespace backend {
namespace vulkan { namespace vulkan {
void Init(nxtProcTable* procs, nxtDevice* device); void Init(nxtProcTable* procs, nxtDevice* device);
@ -22,6 +25,43 @@ namespace backend {
namespace utils { namespace utils {
class SwapChainImplVulkan : SwapChainImpl {
public:
static nxtSwapChainImplementation Create(GLFWwindow* window) {
auto impl = GenerateSwapChainImplementation<SwapChainImplVulkan, nxtWSIContextVulkan>();
impl.userData = new SwapChainImplVulkan(window);
return impl;
}
private:
GLFWwindow* window = nullptr;
SwapChainImplVulkan(GLFWwindow* window)
: window(window) {
}
~SwapChainImplVulkan() {
}
// For GenerateSwapChainImplementation
friend class SwapChainImpl;
void Init(nxtWSIContextVulkan*) {
}
nxtSwapChainError Configure(nxtTextureFormat, nxtTextureUsageBit, uint32_t, uint32_t) {
return NXT_SWAP_CHAIN_NO_ERROR;
}
nxtSwapChainError GetNextTexture(nxtSwapChainNextTexture*) {
return NXT_SWAP_CHAIN_NO_ERROR;
}
nxtSwapChainError Present() {
return NXT_SWAP_CHAIN_NO_ERROR;
}
};
class VulkanBinding : public BackendBinding { class VulkanBinding : public BackendBinding {
public: public:
void SetupGLFWWindowHints() override { void SetupGLFWWindowHints() override {
@ -30,11 +70,17 @@ namespace utils {
backend::vulkan::Init(procs, device); backend::vulkan::Init(procs, device);
} }
uint64_t GetSwapChainImplementation() override { uint64_t GetSwapChainImplementation() override {
return 0; if (swapchainImpl.userData == nullptr) {
swapchainImpl = SwapChainImplVulkan::Create(window);
}
return reinterpret_cast<uint64_t>(&swapchainImpl);
} }
nxtTextureFormat GetPreferredSwapChainTextureFormat() override { nxtTextureFormat GetPreferredSwapChainTextureFormat() override {
return NXT_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM; return NXT_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM;
} }
private:
nxtSwapChainImplementation swapchainImpl = {};
}; };