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