update Vulkan implementation headers
This commit is contained in:
@@ -10,11 +10,9 @@
|
||||
#include <Windows.h>
|
||||
#include <wrl.h>
|
||||
|
||||
|
||||
|
||||
namespace thermion::windows::d3d {
|
||||
|
||||
class EMSCRIPTEN_KEEPALIVE D3DContext {
|
||||
class DLL_EXPORT D3DContext {
|
||||
public:
|
||||
D3DContext();
|
||||
~D3DContext();
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
namespace thermion::windows::d3d {
|
||||
|
||||
class EMSCRIPTEN_KEEPALIVE D3DTexture {
|
||||
class DLL_EXPORT D3DTexture {
|
||||
public:
|
||||
D3DTexture(
|
||||
Microsoft::WRL::ComPtr<ID3D11Texture2D> d3dTexture2D,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifdef THERMION_WIN32_KHR_BUILD
|
||||
#define EMSCRIPTEN_KEEPALIVE __declspec(dllimport)
|
||||
#define DLL_EXPORT __declspec(dllimport)
|
||||
#else
|
||||
#define EMSCRIPTEN_KEEPALIVE __declspec(dllexport)
|
||||
#define DLL_EXPORT __declspec(dllexport)
|
||||
#endif
|
||||
@@ -1,24 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "d3d_context.h"
|
||||
|
||||
#include "vulkan_texture.h"
|
||||
|
||||
#include "vulkan_platform.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
@@ -29,80 +24,31 @@
|
||||
|
||||
namespace thermion::windows::vulkan {
|
||||
|
||||
class TVulkanPlatform : public filament::backend::VulkanPlatform {
|
||||
public:
|
||||
|
||||
TVulkanPlatform() {
|
||||
_customization.gpu.index = 0;
|
||||
}
|
||||
|
||||
virtual VulkanPlatform::Customization getCustomization() const noexcept override {
|
||||
return _customization;
|
||||
}
|
||||
|
||||
SwapChainPtr createSwapChain(void* nativeWindow, uint64_t flags,
|
||||
VkExtent2D extent = {0, 0}) override {
|
||||
std::lock_guard lock(mutex);
|
||||
current = filament::backend::VulkanPlatform::createSwapChain(nativeWindow, flags, extent);
|
||||
std::cout << "Created swap chain with flags " << flags << std::endl;
|
||||
return current;
|
||||
}
|
||||
class DLL_EXPORT ThermionVulkanContext {
|
||||
public:
|
||||
ThermionVulkanContext();
|
||||
~ThermionVulkanContext();
|
||||
|
||||
HANDLE CreateRenderingSurface(uint32_t width, uint32_t height, uint32_t left, uint32_t top);
|
||||
|
||||
void DestroyRenderingSurface(HANDLE handle);
|
||||
|
||||
void ResizeRenderingSurface(uint32_t width, uint32_t height, uint32_t left, uint32_t top);
|
||||
|
||||
void Flush();
|
||||
|
||||
void destroy(SwapChainPtr handle) override {
|
||||
std::lock_guard lock(mutex);
|
||||
current = nullptr;
|
||||
std::cout << "Destroyed swap chain" << std::endl;
|
||||
}
|
||||
|
||||
VkResult present(SwapChainPtr handle, uint32_t index, VkSemaphore finishedDrawing) override {
|
||||
auto result = filament::backend::VulkanPlatform::present(handle, index, finishedDrawing);
|
||||
currentColorIndex = index;
|
||||
return result;
|
||||
}
|
||||
SwapChainPtr current;
|
||||
std::mutex mutex;
|
||||
uint32_t currentColorIndex = 0;
|
||||
|
||||
private:
|
||||
filament::backend::VulkanPlatform::Customization _customization;
|
||||
|
||||
};
|
||||
|
||||
class EMSCRIPTEN_KEEPALIVE ThermionVulkanContext {
|
||||
public:
|
||||
ThermionVulkanContext();
|
||||
void* GetSharedContext();
|
||||
HANDLE CreateRenderingSurface(uint32_t width, uint32_t height, uint32_t left, uint32_t top);
|
||||
void DestroyRenderingSurface(HANDLE handle);
|
||||
void ResizeRenderingSurface(uint32_t width, uint32_t height, uint32_t left, uint32_t top);
|
||||
void Flush();
|
||||
|
||||
filament::backend::VulkanPlatform *GetPlatform() {
|
||||
return _platform;
|
||||
}
|
||||
|
||||
void BlitFromSwapchain();
|
||||
|
||||
void readPixelsFromImage(
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
std::vector<uint8_t>& outPixels
|
||||
);
|
||||
|
||||
|
||||
private:
|
||||
VkInstance instance = VK_NULL_HANDLE;
|
||||
VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
|
||||
VkDevice device = VK_NULL_HANDLE;
|
||||
VkCommandPool commandPool = VK_NULL_HANDLE;
|
||||
VkQueue queue = VK_NULL_HANDLE;
|
||||
|
||||
std::unique_ptr<thermion::windows::d3d::D3DContext> _d3dContext;
|
||||
|
||||
std::vector<std::unique_ptr<thermion::windows::d3d::D3DTexture>> _d3dTextures;
|
||||
std::vector<std::unique_ptr<thermion::windows::vulkan::VulkanTexture>> _vulkanTextures;
|
||||
|
||||
TVulkanPlatform *_platform;
|
||||
};
|
||||
filament::backend::VulkanPlatform *GetPlatform();
|
||||
|
||||
void BlitFromSwapchain();
|
||||
|
||||
void readPixelsFromImage(
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
std::vector<uint8_t>& outPixels);
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
std::unique_ptr<Impl> pImpl;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include "d3d_context.h"
|
||||
#include "vulkan_texture.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
#include "filament/backend/Platform.h"
|
||||
#include "filament/backend/platforms/VulkanPlatform.h"
|
||||
|
||||
#include "import.h"
|
||||
|
||||
namespace thermion::windows::vulkan {
|
||||
|
||||
class TVulkanPlatform : public filament::backend::VulkanPlatform {
|
||||
public:
|
||||
|
||||
TVulkanPlatform();
|
||||
~TVulkanPlatform();
|
||||
|
||||
virtual VulkanPlatform::Customization getCustomization() const noexcept;
|
||||
|
||||
SwapChainPtr createSwapChain(void* nativeWindow, uint64_t flags,
|
||||
VkExtent2D extent = {0, 0}) override;
|
||||
|
||||
void destroy(SwapChainPtr handle) override;
|
||||
|
||||
VkResult present(SwapChainPtr handle, uint32_t index, VkSemaphore finishedDrawing) override;
|
||||
|
||||
SwapChainPtr current;
|
||||
std::mutex mutex;
|
||||
uint32_t currentColorIndex = 0;
|
||||
|
||||
private:
|
||||
filament::backend::VulkanPlatform::Customization _customization;
|
||||
|
||||
};
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include "bluevk/BlueVK.h"
|
||||
@@ -8,7 +10,7 @@ namespace thermion::windows::vulkan {
|
||||
|
||||
typedef void *HANDLE;
|
||||
|
||||
class EMSCRIPTEN_KEEPALIVE VulkanTexture {
|
||||
class DLL_EXPORT VulkanTexture {
|
||||
public:
|
||||
VulkanTexture(VkImage image, VkDevice device, VkDeviceMemory imageMemory, uint32_t width, uint32_t height, HANDLE d3dTextureHandle);
|
||||
~VulkanTexture();
|
||||
|
||||
Reference in New Issue
Block a user