Skip to content

Commit

Permalink
Moved shader code to stdshader_vulkan.dll
Browse files Browse the repository at this point in the history
  • Loading branch information
PazerOP committed May 21, 2019
1 parent ea05907 commit a1adc0d
Show file tree
Hide file tree
Showing 30 changed files with 176 additions and 318 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,4 @@ ASALocalRun/
healthchecksdb
stdshader_dx9_tf2vulkan/src/Generated/
*.vcxproj.filters
stdshader_vulkan/src/shaders/Generated/
12 changes: 0 additions & 12 deletions TF2Vulkan.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,12 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shaderapivulkan", "shaderapivulkan\shaderapivulkan.vcxproj", "{B47D0193-FBE9-4F6D-B722-215E3D12DC15}"
ProjectSection(ProjectDependencies) = postProject
{31135B2A-945B-4440-96EC-724BB0738FC7} = {31135B2A-945B-4440-96EC-724BB0738FC7}
{41ED1D80-2EB6-487C-B63F-45DF53B72BA5} = {41ED1D80-2EB6-487C-B63F-45DF53B72BA5}
{92A717EE-4898-4730-963D-41F6C5015A62} = {92A717EE-4898-4730-963D-41F6C5015A62}
{BCAA3EF6-6521-4314-A301-BF1D2FB740C5} = {BCAA3EF6-6521-4314-A301-BF1D2FB740C5}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TF2VulkanUtil", "TF2VulkanUtil\TF2VulkanUtil.vcxproj", "{BCAA3EF6-6521-4314-A301-BF1D2FB740C5}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stdshader_dx9_tf2vulkan", "stdshader_dx9_tf2vulkan\stdshader_dx9_tf2vulkan.vcxproj", "{41ED1D80-2EB6-487C-B63F-45DF53B72BA5}"
ProjectSection(ProjectDependencies) = postProject
{BCAA3EF6-6521-4314-A301-BF1D2FB740C5} = {BCAA3EF6-6521-4314-A301-BF1D2FB740C5}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "spirv-cross", "spirv-cross-project\spirv-cross.vcxproj", "{31135B2A-945B-4440-96EC-724BB0738FC7}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stdshader_vulkan", "stdshader_vulkan\stdshader_vulkan.vcxproj", "{92A717EE-4898-4730-963D-41F6C5015A62}"
Expand Down Expand Up @@ -65,12 +59,6 @@ Global
{BCAA3EF6-6521-4314-A301-BF1D2FB740C5}.Release|x64.ActiveCfg = Release|Win32
{BCAA3EF6-6521-4314-A301-BF1D2FB740C5}.Release|x86.ActiveCfg = Release|Win32
{BCAA3EF6-6521-4314-A301-BF1D2FB740C5}.Release|x86.Build.0 = Release|Win32
{41ED1D80-2EB6-487C-B63F-45DF53B72BA5}.Debug|x64.ActiveCfg = Debug|Win32
{41ED1D80-2EB6-487C-B63F-45DF53B72BA5}.Debug|x86.ActiveCfg = Debug|Win32
{41ED1D80-2EB6-487C-B63F-45DF53B72BA5}.Debug|x86.Build.0 = Debug|Win32
{41ED1D80-2EB6-487C-B63F-45DF53B72BA5}.Release|x64.ActiveCfg = Release|Win32
{41ED1D80-2EB6-487C-B63F-45DF53B72BA5}.Release|x86.ActiveCfg = Release|Win32
{41ED1D80-2EB6-487C-B63F-45DF53B72BA5}.Release|x86.Build.0 = Release|Win32
{31135B2A-945B-4440-96EC-724BB0738FC7}.Debug|x64.ActiveCfg = Debug|Win32
{31135B2A-945B-4440-96EC-724BB0738FC7}.Debug|x86.ActiveCfg = Debug|Win32
{31135B2A-945B-4440-96EC-724BB0738FC7}.Debug|x86.Build.0 = Debug|Win32
Expand Down
27 changes: 15 additions & 12 deletions TF2VulkanUtil/include/TF2Vulkan/Util/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,23 @@ inline CreateInterfaceFn Sys_GetFactory(CSysModule* pModule)
return TF2Vulkan::Sys_GetFactoryCustom(pModule);
}

template<typename T>
inline void ConnectInterface(CreateInterfaceFn factory, const char* interfaceName, T*& interfacePtr)
#endif

namespace Util
{
if (!factory)
template<typename T>
inline void ConnectInterface(CreateInterfaceFn factory, const char* interfaceName, T*& interfacePtr)
{
assert(factory);
Error("[TF2Vulkan] " __FUNCTION__ "(): Factory was null");
}
if (!factory)
{
assert(factory);
Error("[TF2Vulkan] " __FUNCTION__ "(): Factory was null");
}

if (!(interfacePtr = (T*)factory(interfaceName, nullptr)))
{
assert(interfacePtr);
Error("[TF2Vulkan] " __FUNCTION__ "(): Failed to connect to %s", interfaceName);
if (!(interfacePtr = (T*)factory(interfaceName, nullptr)))
{
assert(interfacePtr);
Error("[TF2Vulkan] " __FUNCTION__ "(): Failed to connect to %s", interfaceName);
}
}
}

#endif
2 changes: 1 addition & 1 deletion TF2Vulkan_Shared_Solution.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>RAD_TELEMETRY_DISABLED;CUSTOM_CREATEINTERFACE_FN;_CRT_SECURE_NO_WARNINGS;_PREFAST_;TF2VULKAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>RAD_TELEMETRY_DISABLED;_CRT_SECURE_NO_WARNINGS;_PREFAST_;TF2VULKAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)src;$(ProjectDir)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpplatest</LanguageStandard>
<WarningLevel>Level3</WarningLevel>
Expand Down
8 changes: 3 additions & 5 deletions shaderapivulkan/shaderapivulkan.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,18 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\TF2Vulkan_Shared_Solution.props" />
<Import Project="..\TF2VulkanUtil\TF2VulkanUtil_Link.props" />
<Import Project="..\stdshader_dx9_tf2vulkan\stdshader_dx9_tf2vulkan_Link.props" />
<Import Project="..\stdshader_vulkan\stdshader_vulkan_Link.props" />
<Import Project="shaderapivulkan_Shared_Project.props" />
<Import Project="..\spirv-cross-project\spirv-cross_Link.props" />
<Import Project="..\stdshader_vulkan\stdshader_vulkan_Link.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\TF2Vulkan_Shared_Solution.props" />
<Import Project="..\TF2VulkanUtil\TF2VulkanUtil_Link.props" />
<Import Project="..\stdshader_dx9_tf2vulkan\stdshader_dx9_tf2vulkan_Link.props" />
<Import Project="..\stdshader_vulkan\stdshader_vulkan_Link.props" />
<Import Project="shaderapivulkan_Shared_Project.props" />
<Import Project="..\spirv-cross-project\spirv-cross_Link.props" />
<Import Project="..\TF2Vulkan_Release_Solution.props" />
<Import Project="..\stdshader_vulkan\stdshader_vulkan_Link.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
Expand Down Expand Up @@ -185,4 +183,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
10 changes: 10 additions & 0 deletions shaderapivulkan/src/TF2Vulkan/ShaderDeviceMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "interface/internal/IShaderDeviceMgrInternal.h"
#include "interface/internal/IShaderDeviceInternal.h"

#include <stdshader_vulkan/ShaderBlobs.h>
#include <TF2Vulkan/Util/interface.h>
#include <TF2Vulkan/Util/std_algorithm.h>

Expand Down Expand Up @@ -97,6 +98,9 @@ EXPOSE_SINGLE_INTERFACE_GLOBALVAR(ShaderDeviceMgr, IShaderDeviceMgr, SHADER_DEVI

IShaderDeviceMgrInternal& TF2Vulkan::g_ShaderDeviceMgr = s_DeviceMgr;

static CDllDemandLoader s_StdShaderVulkanDll("stdshader_vulkan");
const IShaderBlobs* TF2Vulkan::g_ShaderBlobs;

static ConVar mat_alphacoverage("mat_alphacoverage", "0");
static ConVar mat_frame_sync_enable("mat_frame_sync_enable", "1");
static ConVar r_pixelfog("r_pixelfog", "1");
Expand Down Expand Up @@ -128,6 +132,12 @@ bool ShaderDeviceMgr::Connect(CreateInterfaceFn factory)
" on the command line (advanced options) to disable access to VAC-secured servers.");
}

// Interfaces from stdshader_vulkan
{
auto stdshaderVulkanFactory = s_StdShaderVulkanDll.GetFactory();
Util::ConnectInterface(stdshaderVulkanFactory, SHADER_BLOBS_INTERFACE_VERSION, g_ShaderBlobs);
}

// MatSystemSurface normally adds 0.5 to vgui coordinates, unless
// these command line parameters are present, in which case it
// gets the offset from the params. We aren't DX9, so we don't
Expand Down
24 changes: 12 additions & 12 deletions shaderapivulkan/src/TF2Vulkan/shaders/VulkanShaderManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <TF2Vulkan/Util/Buffer.h>
#include <TF2Vulkan/Util/std_utility.h>
#include <stdshader_dx9_tf2vulkan/ShaderBlobs.h>
#include <stdshader_vulkan/ShaderBlobs.h>

#include <materialsystem/shader_vcs_version.h>

Expand All @@ -19,12 +19,12 @@ namespace
{
struct ShaderInfo
{
constexpr ShaderInfo(ShaderBlob blob) :
constexpr ShaderInfo(ShaderBlobType blob) :
m_Blob(blob)
{
}

ShaderBlob m_Blob;
ShaderBlobType m_Blob;
};

class VulkanShaderManager final : public IVulkanShaderManager
Expand Down Expand Up @@ -56,14 +56,14 @@ IVulkanShaderManager& TF2Vulkan::g_ShaderManager = s_ShaderManager;

static const std::unordered_map<std::string_view, ShaderInfo> s_ShaderBlobMapping =
{
{ "bik_vs20", { ShaderBlob::Bik_VS } },
{ "bik_ps20b", { ShaderBlob::Bik_PS } },
{ "bufferclearobeystencil_vs", { ShaderBlob::BufferClearObeyStencil_VS } },
{ "bufferclearobeystencil_ps", { ShaderBlob::BufferClearObeyStencil_PS } },
{ "fillrate_vs", { ShaderBlob::Fillrate_VS } },
{ "fillrate_ps", { ShaderBlob::Fillrate_PS } },
{ "xlitgeneric_vs", { ShaderBlob::XLitGeneric_VS } },
{ "xlitgeneric_ps", { ShaderBlob::XLitGeneric_PS } },
{ "bik_vs20", { ShaderBlobType::Bik_VS } },
{ "bik_ps20b", { ShaderBlobType::Bik_PS } },
{ "bufferclearobeystencil_vs", { ShaderBlobType::BufferClearObeyStencil_VS } },
{ "bufferclearobeystencil_ps", { ShaderBlobType::BufferClearObeyStencil_PS } },
{ "fillrate_vs", { ShaderBlobType::Fillrate_VS } },
{ "fillrate_ps", { ShaderBlobType::Fillrate_PS } },
{ "xlitgeneric_vs", { ShaderBlobType::XLitGeneric_VS } },
{ "xlitgeneric_ps", { ShaderBlobType::XLitGeneric_PS } },
};

auto VulkanShaderManager::FindOrCreateShader(const CUtlSymbolDbg& id) -> const TF2Vulkan::IVulkanShader&
Expand Down Expand Up @@ -228,7 +228,7 @@ VulkanShaderManager::CompiledShader::CompiledShader(const CUtlSymbolDbg& name) :
vk::ShaderModuleCreateInfo ci;

const void* blobData;
if (!TF2Vulkan::GetShaderBlob(shaderInfo.m_Blob, blobData, ci.codeSize))
if (!g_ShaderBlobs->GetShaderBlob(shaderInfo.m_Blob, blobData, ci.codeSize))
throw VulkanException("Failed to get shader blob", EXCEPTION_DATA());

ci.pCode = reinterpret_cast<const uint32_t*>(blobData);
Expand Down

This file was deleted.

46 changes: 0 additions & 46 deletions stdshader_dx9_tf2vulkan/src/ShaderBlobs.cpp

This file was deleted.

Loading

0 comments on commit a1adc0d

Please sign in to comment.