made it work with new fpc

This commit is contained in:
2026-02-01 17:47:49 +02:00
parent fe1273e539
commit faae0bdcc7
199 changed files with 355 additions and 14541 deletions

View File

@@ -1,4 +1,3 @@
#include "SDL3/SDL_vulkan.h"
#include "commands.h"
#include "materialsystem/imaterialsystem.h"
#include "tier0/lib.h"
@@ -250,14 +249,7 @@ public:
virtual void Init() override;
virtual void Frame( float fDeltaTime ) override;
virtual void Shutdown() override;
virtual void SetOutputImage( IImage *pImage ) override;
virtual bool BIsOutputImageOutdated() override;
virtual uint32_t GetNewOutputImageWidth() override;
virtual uint32_t GetNewOutputImageHeight() override;
virtual EImageFormat GetNewOutputImageFormat() override;
virtual IVertexBuffer *CreateVertexBuffer( uint32_t nSize ) override;
virtual IIndexBuffer *CreateIndexBuffer( uint32_t nSize ) override;
virtual IBuffer *CreateConstantBuffer( uint32_t nSize ) override;
@@ -280,45 +272,24 @@ public:
virtual IRenderCommandList *CreateCommandList() override;
virtual void DestroyCommandList( IRenderCommandList *pCommandList ) override;
virtual void SubmitCommandList(IRenderCommandList *pList) override;
virtual void SetMainWindowManager( IGameWindowManager *pWindowManager ) override;
virtual void RenderGameWindow( IGameWindow *pWindow ) override;
virtual void RegisterGameWindow( IGameWindow *pWindow ) override;
virtual void UnregisterGameWindow( IGameWindow *pWindow ) override;
private:
VkPhysicalDevice SelectPhysicalDevice( CUtlVector<VkPhysicalDevice> physicalDevices );
CUtlVector<const char *> GetDeviceExtensions();
VkCommandBuffer GetCommandBuffer();
void CreateSwapchain();
void DestroySwapchain();
void CreateSwapchain( IGameWindow *pWindow );
void DestroySwapchain( IGameWindow *pWindow );
IImage *m_pOutputImage = NULL;
bool m_bOutputImageOutdated = true;
IGameWindowManager *m_pWindowManager;
};
EXPOSE_INTERFACE(CVkRenderContext, IRenderContext, RENDER_CONTEXT_VULKAN_INTERFACE_NAME);
void CVkRenderContext::SetOutputImage( IImage *pImage )
{
m_pOutputImage = pImage;
}
bool CVkRenderContext::BIsOutputImageOutdated( )
{
return m_bOutputImageOutdated;
}
uint32_t CVkRenderContext::GetNewOutputImageWidth()
{
return 1280;
}
uint32_t CVkRenderContext::GetNewOutputImageHeight()
{
return 720;
}
EImageFormat CVkRenderContext::GetNewOutputImageFormat()
{
}
EXPOSE_INTERFACE(CVkRenderContext, IRenderContext, RENDER_CONTEXT_INTERFACE_VERSION);
//-----------------------------------------------------------------------------
@@ -424,7 +395,6 @@ IShader *CVkRenderContext::CreateShader( const char *szName )
pShader->AddShaderLibrary(&vertexTransform);
pShader->AddShaderLibrary(&pixelShader);
pShader->AddShaderLibrary(&pixelOutput);
printf("--- general pipeline ---\n");
pShader->Build();
return pShader;
}
@@ -459,6 +429,26 @@ void CVkRenderContext::SubmitCommandList(IRenderCommandList *pList)
CVkRenderCommandList *pVkList = (CVkRenderCommandList*)pList;
pVkList->Submit();
}
void CVkRenderContext::RenderGameWindow( IGameWindow *pWindow )
{
}
void CVkRenderContext::SetMainWindowManager( IGameWindowManager *pWindowManager )
{
m_pWindowManager = pWindowManager;
}
void CVkRenderContext::RegisterGameWindow( IGameWindow *pWindow )
{
}
void CVkRenderContext::UnregisterGameWindow( IGameWindow *pWindow )
{
}
VkPipelineLayout g_pLibraryEmptyLayout;
static IVkCommandBuffer *s_pPresentCommandBuffer;
@@ -488,10 +478,17 @@ void CVkRenderContext::Init()
r = volkInitialize();
VULKAN_RESULT_PRINT(r, volkInitialize);
// Get extensions required by game window
nExtensionCount = gamewindow->GetVulkanInstanceExtensionCount();
enabledInstanceExtensions.Resize(nExtensionCount);
V_memcpy(enabledInstanceExtensions.GetData(), gamewindow->GetVulkanInstanceExtensions(), enabledInstanceExtensions.GetSize()*sizeof(const char*));
if (m_pWindowManager)
{
nExtensionCount = m_pWindowManager->GetVulkanInstanceExtensionCount();
enabledInstanceExtensions.Resize(nExtensionCount);
V_memcpy(
enabledInstanceExtensions.GetData(),
m_pWindowManager->GetVulkanInstanceExtensions(),
nExtensionCount*sizeof(const char*)
);
}
// Create instance
stApplicationInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
@@ -596,8 +593,6 @@ void CVkRenderContext::Init()
stPipelineLayout.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
stPipelineLayout.flags = VK_PIPELINE_LAYOUT_CREATE_INDEPENDENT_SETS_BIT_EXT;
vkCreatePipelineLayout(g_vkDevice, &stPipelineLayout, NULL, &g_pLibraryEmptyLayout);
CreateSwapchain();
g_vkCommandPools.Resize(g_vkSwapchainImages.GetSize());
@@ -619,6 +614,7 @@ void CVkRenderContext::Init()
void CVkRenderContext::Frame( float fDeltaTime )
{
/*
CVkBlitCommand *pBlitCommand = NULL;
if (m_pOutputImage)
{
@@ -643,7 +639,6 @@ void CVkRenderContext::Frame( float fDeltaTime )
s_pPresentCommandBuffer->Render();
vkDeviceWaitIdle(g_vkDevice);
m_bOutputImageOutdated = false;
static uint32_t s_nImageIndex = 0;
uint32_t nImageIndex = 0;
@@ -684,9 +679,10 @@ void CVkRenderContext::Frame( float fDeltaTime )
s_nImageIndex = (s_nImageIndex + 1) % g_vkSwapchainImages.GetSize();
g_vkCommandBuffers = {};
*/
}
void CVkRenderContext::CreateSwapchain()
void CVkRenderContext::CreateSwapchain( IGameWindow *pWindow )
{
uint32_t numSurfaceFormats = 0;
CUtlVector<VkSurfaceFormatKHR> surfaceFormats;
@@ -708,16 +704,17 @@ void CVkRenderContext::CreateSwapchain()
uint32_t nSwapchainImages;
CUtlVector<VkImage> swapchainImages;
VkSurfaceKHR hSurface;
gamewindow->CreateVulkanSurface(g_vkInstance);
hSurface = (VkSurfaceKHR)pWindow->CreateVulkanSurface(g_vkInstance);
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(g_vkPhysicalDevice, (VkSurfaceKHR)gamewindow->GetVulkanSurface(), &surfaceCapatibilities);
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(g_vkPhysicalDevice, (VkSurfaceKHR)hSurface, &surfaceCapatibilities);
vkGetPhysicalDeviceSurfaceFormatsKHR(g_vkPhysicalDevice, (VkSurfaceKHR)gamewindow->GetVulkanSurface(), &numSurfaceFormats, NULL);
vkGetPhysicalDeviceSurfaceFormatsKHR(g_vkPhysicalDevice, (VkSurfaceKHR)hSurface, &numSurfaceFormats, NULL);
surfaceFormats.Resize(numSurfaceFormats);
vkGetPhysicalDeviceSurfaceFormatsKHR(g_vkPhysicalDevice, (VkSurfaceKHR)gamewindow->GetVulkanSurface(), &numSurfaceFormats, surfaceFormats.GetData());
vkGetPhysicalDeviceSurfaceFormatsKHR(g_vkPhysicalDevice, (VkSurfaceKHR)hSurface, &numSurfaceFormats, surfaceFormats.GetData());
stSelectedFormat = surfaceFormats[0];
@@ -734,12 +731,12 @@ void CVkRenderContext::CreateSwapchain()
}
formatPicked:
vkGetPhysicalDeviceSurfacePresentModesKHR(g_vkPhysicalDevice, (VkSurfaceKHR)gamewindow->GetVulkanSurface(), &nSurfacePresentModes, NULL);
vkGetPhysicalDeviceSurfacePresentModesKHR(g_vkPhysicalDevice, hSurface, &nSurfacePresentModes, NULL);
surfacePresentModes.Resize(nSurfacePresentModes);
vkGetPhysicalDeviceSurfacePresentModesKHR(g_vkPhysicalDevice, (VkSurfaceKHR)gamewindow->GetVulkanSurface(), &nSurfacePresentModes, surfacePresentModes.GetData());
vkGetPhysicalDeviceSurfacePresentModesKHR(g_vkPhysicalDevice, hSurface, &nSurfacePresentModes, surfacePresentModes.GetData());
stSwapchainCreateInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
stSwapchainCreateInfo.surface = (VkSurfaceKHR)gamewindow->GetVulkanSurface();
stSwapchainCreateInfo.surface = hSurface;
stSwapchainCreateInfo.imageFormat = stSelectedFormat.format;
stSwapchainCreateInfo.imageColorSpace = stSelectedFormat.colorSpace;
stSwapchainCreateInfo.presentMode = VK_PRESENT_MODE_IMMEDIATE_KHR;
@@ -786,10 +783,10 @@ formatPicked:
}
void CVkRenderContext::DestroySwapchain()
void CVkRenderContext::DestroySwapchain( IGameWindow *pWindow )
{
vkDestroySwapchainKHR(g_vkDevice, g_vkSwapchain, NULL);
gamewindow->DestroyVulkanSurface(g_vkInstance);
pWindow->DestroyVulkanSurface(g_vkInstance);
}
//-----------------------------------------------------------------------------